@atlaskit/editor-core 185.2.0 → 185.2.5
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 +14 -0
- package/dist/cjs/actions/index.js +2 -2
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +1 -2
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/cjs/messages.js +6 -56
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +2 -2
- package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +2 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +6 -6
- package/dist/cjs/plugins/card/nodeviews/genericCard.js +2 -1
- package/dist/cjs/plugins/card/pm-plugins/doc.js +9 -11
- package/dist/cjs/plugins/card/pm-plugins/keymap.js +3 -6
- package/dist/cjs/plugins/card/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/card/toolbar.js +13 -16
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +19 -18
- package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +7 -10
- package/dist/cjs/plugins/card/utils.js +3 -4
- package/dist/cjs/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/cjs/plugins/custom-autoformat/doc.js +1 -1
- package/dist/cjs/plugins/date/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/emoji/index.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/index.js +8 -2
- package/dist/cjs/plugins/hyperlink/Toolbar.js +8 -8
- package/dist/cjs/plugins/hyperlink/commands.js +2 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/cjs/plugins/layout/actions.js +1 -1
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -2
- package/dist/cjs/plugins/media/toolbar/index.js +10 -9
- package/dist/cjs/plugins/media/toolbar/linking-toolbar-appearance.js +4 -3
- package/dist/cjs/plugins/media/toolbar/linking.js +6 -6
- package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +6 -8
- package/dist/cjs/plugins/media/utils/media-files.js +8 -7
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/placeholder/index.js +2 -3
- package/dist/cjs/plugins/status/plugin.js +2 -2
- package/dist/cjs/plugins/unsupported-content/index.js +3 -3
- package/dist/cjs/ui/LinkSearch/ToolbarComponents.js +4 -11
- package/dist/cjs/utils/document.js +7 -249
- package/dist/cjs/utils/index.js +1 -23
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +2 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/es2019/messages.js +2 -54
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +3 -3
- package/dist/es2019/plugins/card/nodeviews/genericCard.js +2 -1
- package/dist/es2019/plugins/card/pm-plugins/doc.js +2 -3
- package/dist/es2019/plugins/card/pm-plugins/keymap.js +3 -3
- package/dist/es2019/plugins/card/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/card/toolbar.js +8 -10
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +10 -8
- package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +1 -4
- package/dist/es2019/plugins/card/utils.js +1 -2
- package/dist/es2019/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/es2019/plugins/custom-autoformat/doc.js +1 -1
- package/dist/es2019/plugins/date/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/emoji/index.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +5 -2
- package/dist/es2019/plugins/hyperlink/Toolbar.js +3 -3
- package/dist/es2019/plugins/hyperlink/commands.js +1 -2
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
- package/dist/es2019/plugins/layout/actions.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
- package/dist/es2019/plugins/media/toolbar/index.js +10 -9
- package/dist/es2019/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
- package/dist/es2019/plugins/media/toolbar/linking.js +4 -4
- package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
- package/dist/es2019/plugins/media/utils/media-files.js +4 -3
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/placeholder/index.js +1 -1
- package/dist/es2019/plugins/status/plugin.js +1 -1
- package/dist/es2019/plugins/unsupported-content/index.js +1 -1
- package/dist/es2019/ui/LinkSearch/ToolbarComponents.js +1 -4
- package/dist/es2019/utils/document.js +3 -244
- package/dist/es2019/utils/index.js +1 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +2 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/esm/messages.js +2 -54
- package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/esm/plugins/card/nodeviews/embedCard.js +3 -3
- package/dist/esm/plugins/card/nodeviews/genericCard.js +2 -1
- package/dist/esm/plugins/card/pm-plugins/doc.js +2 -3
- package/dist/esm/plugins/card/pm-plugins/keymap.js +3 -3
- package/dist/esm/plugins/card/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/card/toolbar.js +8 -10
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +18 -16
- package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +1 -4
- package/dist/esm/plugins/card/utils.js +1 -2
- package/dist/esm/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
- package/dist/esm/plugins/date/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/emoji/index.js +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +5 -2
- package/dist/esm/plugins/hyperlink/Toolbar.js +3 -3
- package/dist/esm/plugins/hyperlink/commands.js +1 -2
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
- package/dist/esm/plugins/layout/actions.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
- package/dist/esm/plugins/media/toolbar/index.js +10 -9
- package/dist/esm/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
- package/dist/esm/plugins/media/toolbar/linking.js +4 -4
- package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
- package/dist/esm/plugins/media/utils/media-files.js +4 -3
- package/dist/esm/plugins/mentions/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/placeholder/index.js +1 -1
- package/dist/esm/plugins/status/plugin.js +1 -1
- package/dist/esm/plugins/unsupported-content/index.js +1 -1
- package/dist/esm/ui/LinkSearch/ToolbarComponents.js +1 -4
- package/dist/esm/utils/document.js +6 -240
- package/dist/esm/utils/index.js +1 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/labs/next/presets/cxhtml.d.ts +9 -3
- package/dist/types/labs/next/presets/default.d.ts +13 -1
- package/dist/types/labs/next/presets/mobile.d.ts +9 -3
- package/dist/types/messages.d.ts +2 -53
- package/dist/types/plugins/card/index.d.ts +3 -1
- package/dist/types/plugins/card/nodeviews/blockCard.d.ts +1 -1
- package/dist/types/plugins/card/nodeviews/genericCard.d.ts +3 -3
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types/plugins/card/toolbar.d.ts +1 -1
- package/dist/types/plugins/card/types.d.ts +1 -1
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
- package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types/plugins/date/nodeviews/date.d.ts +1 -1
- package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/index.d.ts +2 -6
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/Toolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/commands.d.ts +2 -3
- package/dist/types/plugins/hyperlink/index.d.ts +1 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types/plugins/media/index.d.ts +3 -1
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/types.d.ts +1 -1
- package/dist/types/plugins/media/toolbar/linking.d.ts +3 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
- package/dist/types/plugins/media/utils/media-files.d.ts +1 -1
- package/dist/types/plugins/mentions/nodeviews/mention.d.ts +1 -1
- package/dist/types/plugins/status/nodeviews/status.d.ts +1 -1
- package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
- package/dist/types/utils/document.d.ts +0 -12
- package/dist/types/utils/index.d.ts +1 -2
- package/dist/types-ts4.5/index.d.ts +1 -2
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +9 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +13 -1
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +9 -3
- package/dist/types-ts4.5/messages.d.ts +2 -53
- package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +3 -3
- package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
- package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +1 -1
- package/dist/types-ts4.5/plugins/emoji/nodeviews/emoji.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +2 -9
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/commands.d.ts +2 -3
- package/dist/types-ts4.5/plugins/hyperlink/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/toolbar/linking.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -1
- package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +1 -1
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +1 -1
- package/dist/types-ts4.5/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
- package/dist/types-ts4.5/utils/document.d.ts +0 -12
- package/dist/types-ts4.5/utils/index.d.ts +1 -2
- package/package.json +11 -14
- package/report.api.md +11 -34
- package/tmp/api-report-tmp.d.ts +10 -34
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.js +0 -227
- package/dist/cjs/plugins/hyperlink/types.js +0 -5
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +0 -152
- package/dist/cjs/ui/Resizer/index.js +0 -210
- package/dist/cjs/ui/Resizer/styled.js +0 -15
- package/dist/cjs/ui/Resizer/types.js +0 -5
- package/dist/cjs/ui/Resizer/utils.js +0 -21
- package/dist/cjs/utils/filter/privacy-filter.js +0 -55
- package/dist/cjs/utils/linking-utils.js +0 -84
- package/dist/cjs/utils/rich-media-utils.js +0 -130
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.js +0 -221
- package/dist/es2019/plugins/hyperlink/types.js +0 -1
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +0 -159
- package/dist/es2019/ui/Resizer/index.js +0 -191
- package/dist/es2019/ui/Resizer/styled.js +0 -15
- package/dist/es2019/ui/Resizer/types.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -12
- package/dist/es2019/utils/filter/privacy-filter.js +0 -47
- package/dist/es2019/utils/linking-utils.js +0 -74
- package/dist/es2019/utils/rich-media-utils.js +0 -108
- package/dist/esm/nodeviews/getInlineNodeViewProducer.js +0 -217
- package/dist/esm/plugins/hyperlink/types.js +0 -1
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +0 -144
- package/dist/esm/ui/Resizer/index.js +0 -203
- package/dist/esm/ui/Resizer/styled.js +0 -7
- package/dist/esm/ui/Resizer/types.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -12
- package/dist/esm/utils/filter/privacy-filter.js +0 -48
- package/dist/esm/utils/linking-utils.js +0 -74
- package/dist/esm/utils/rich-media-utils.js +0 -117
- package/dist/types/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
- package/dist/types/plugins/hyperlink/types.d.ts +0 -35
- package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
- package/dist/types/ui/Resizer/index.d.ts +0 -41
- package/dist/types/ui/Resizer/styled.d.ts +0 -2
- package/dist/types/ui/Resizer/types.d.ts +0 -26
- package/dist/types/ui/Resizer/utils.d.ts +0 -6
- package/dist/types/utils/filter/privacy-filter.d.ts +0 -9
- package/dist/types/utils/linking-utils.d.ts +0 -14
- package/dist/types/utils/rich-media-utils.d.ts +0 -8
- package/dist/types-ts4.5/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
- package/dist/types-ts4.5/plugins/hyperlink/types.d.ts +0 -35
- package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
- package/dist/types-ts4.5/ui/Resizer/index.d.ts +0 -41
- package/dist/types-ts4.5/ui/Resizer/styled.d.ts +0 -2
- package/dist/types-ts4.5/ui/Resizer/types.d.ts +0 -26
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -6
- package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +0 -9
- package/dist/types-ts4.5/utils/linking-utils.d.ts +0 -14
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +0 -8
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.sanitizeNodeForPrivacy = sanitizeNodeForPrivacy;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _traverse = require("@atlaskit/adf-utils/traverse");
|
|
10
|
-
var _resource = require("@atlaskit/mention/resource");
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
/**
|
|
14
|
-
* Sanitises a document where some content should not be in the document (e.g. mention names).
|
|
15
|
-
*
|
|
16
|
-
* It is expected that these names we be resolved separately (e.g. when rendering
|
|
17
|
-
* a node view).
|
|
18
|
-
*/
|
|
19
|
-
function sanitizeNodeForPrivacy(json, providerFactory) {
|
|
20
|
-
var mentionNames = new Map();
|
|
21
|
-
var hasCacheableMentions = false;
|
|
22
|
-
var sanitizedJSON = (0, _traverse.traverse)(json, {
|
|
23
|
-
mention: function mention(node) {
|
|
24
|
-
if (node.attrs && node.attrs.text) {
|
|
25
|
-
hasCacheableMentions = true;
|
|
26
|
-
// Remove @ prefix
|
|
27
|
-
var text = node.attrs.text;
|
|
28
|
-
var name = text.startsWith('@') ? text.slice(1) : text;
|
|
29
|
-
mentionNames.set(node.attrs.id, name);
|
|
30
|
-
}
|
|
31
|
-
return _objectSpread(_objectSpread({}, node), {}, {
|
|
32
|
-
attrs: _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
33
|
-
text: ''
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (hasCacheableMentions && providerFactory) {
|
|
39
|
-
var handler = function handler(_name, providerPromise) {
|
|
40
|
-
if (providerPromise) {
|
|
41
|
-
providerPromise.then(function (provider) {
|
|
42
|
-
if ((0, _resource.isResolvingMentionProvider)(provider)) {
|
|
43
|
-
mentionNames.forEach(function (name, id) {
|
|
44
|
-
provider.cacheMentionName(id, name);
|
|
45
|
-
});
|
|
46
|
-
mentionNames.clear();
|
|
47
|
-
providerFactory.unsubscribe('mentionProvider', handler);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
providerFactory.subscribe('mentionProvider', handler);
|
|
53
|
-
}
|
|
54
|
-
return sanitizedJSON;
|
|
55
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
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 _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var buildEditLinkPayload = function buildEditLinkPayload(type) {
|
|
9
|
-
return {
|
|
10
|
-
action: _analytics.ACTION.CLICKED,
|
|
11
|
-
actionSubject: type === _analytics.ACTION_SUBJECT_ID.HYPERLINK ? _analytics.ACTION_SUBJECT.HYPERLINK : _analytics.ACTION_SUBJECT.SMART_LINK,
|
|
12
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.EDIT_LINK,
|
|
13
|
-
attributes: type !== _analytics.ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
14
|
-
display: type
|
|
15
|
-
} : {},
|
|
16
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.buildEditLinkPayload = buildEditLinkPayload;
|
|
20
|
-
var mapLinkTypeToCardAppearance = function mapLinkTypeToCardAppearance(type) {
|
|
21
|
-
switch (type) {
|
|
22
|
-
case _analytics.ACTION_SUBJECT_ID.CARD_INLINE:
|
|
23
|
-
{
|
|
24
|
-
return 'inline';
|
|
25
|
-
}
|
|
26
|
-
case _analytics.ACTION_SUBJECT_ID.CARD_BLOCK:
|
|
27
|
-
{
|
|
28
|
-
return 'block';
|
|
29
|
-
}
|
|
30
|
-
case _analytics.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 === _analytics.ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
42
|
-
action: _analytics.ACTION.VISITED,
|
|
43
|
-
actionSubject: _analytics.ACTION_SUBJECT.HYPERLINK,
|
|
44
|
-
actionSubjectId: undefined,
|
|
45
|
-
attributes: {
|
|
46
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR
|
|
47
|
-
},
|
|
48
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
49
|
-
} : {
|
|
50
|
-
action: _analytics.ACTION.VISITED,
|
|
51
|
-
actionSubject: _analytics.ACTION_SUBJECT.SMART_LINK,
|
|
52
|
-
actionSubjectId: type,
|
|
53
|
-
attributes: {
|
|
54
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR
|
|
55
|
-
},
|
|
56
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.buildVisitedLinkPayload = buildVisitedLinkPayload;
|
|
60
|
-
var buildOpenedSettingsPayload = function buildOpenedSettingsPayload(type) {
|
|
61
|
-
return {
|
|
62
|
-
action: _analytics.ACTION.CLICKED,
|
|
63
|
-
actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
|
|
64
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
|
|
65
|
-
attributes: {
|
|
66
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
67
|
-
display: mapLinkTypeToCardAppearance(type)
|
|
68
|
-
},
|
|
69
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
exports.buildOpenedSettingsPayload = buildOpenedSettingsPayload;
|
|
73
|
-
var unlinkPayload = function unlinkPayload(type) {
|
|
74
|
-
return {
|
|
75
|
-
action: _analytics.ACTION.UNLINK,
|
|
76
|
-
actionSubject: type === _analytics.ACTION_SUBJECT_ID.HYPERLINK ? _analytics.ACTION_SUBJECT.HYPERLINK : _analytics.ACTION_SUBJECT.SMART_LINK,
|
|
77
|
-
actionSubjectId: type === _analytics.ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
|
|
78
|
-
attributes: {
|
|
79
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR
|
|
80
|
-
},
|
|
81
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
exports.unlinkPayload = unlinkPayload;
|
|
@@ -1,130 +0,0 @@
|
|
|
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 _ui = require("@atlaskit/editor-common/ui");
|
|
12
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
13
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
var nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
17
|
-
exports.nonWrappedLayouts = nonWrappedLayouts;
|
|
18
|
-
var floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
19
|
-
exports.floatingLayouts = floatingLayouts;
|
|
20
|
-
var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
|
|
21
|
-
if (typeof pos !== 'number' || isNaN(pos) || !view) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
var $pos = view.state.doc.resolve(pos);
|
|
25
|
-
var _view$state$schema$no = view.state.schema.nodes,
|
|
26
|
-
expand = _view$state$schema$no.expand,
|
|
27
|
-
nestedExpand = _view$state$schema$no.nestedExpand,
|
|
28
|
-
layoutColumn = _view$state$schema$no.layoutColumn;
|
|
29
|
-
return !!(0, _prosemirrorUtils.findParentNodeOfTypeClosestToPos)($pos, [expand, nestedExpand, layoutColumn]);
|
|
30
|
-
};
|
|
31
|
-
exports.isRichMediaInsideOfBlockNode = isRichMediaInsideOfBlockNode;
|
|
32
|
-
var alignAttributes = function alignAttributes(layout, oldAttrs) {
|
|
33
|
-
var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
|
|
34
|
-
var originalWidth = arguments.length > 3 ? arguments[3] : undefined;
|
|
35
|
-
var lineLength = arguments.length > 4 ? arguments[4] : undefined;
|
|
36
|
-
var width = oldAttrs.width;
|
|
37
|
-
var oldLayout = oldAttrs.layout;
|
|
38
|
-
var oldLayoutIsNonWrapped = nonWrappedLayouts.indexOf(oldLayout) > -1;
|
|
39
|
-
var newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
|
|
40
|
-
var newLayoutIsWrapped = _ui.wrappedLayouts.indexOf(layout) > -1;
|
|
41
|
-
var oldLayoutIsWrapped = _ui.wrappedLayouts.indexOf(oldLayout) > -1;
|
|
42
|
-
if (oldLayoutIsNonWrapped && (0, _ui.shouldAddDefaultWrappedWidth)(layout, originalWidth, lineLength)) {
|
|
43
|
-
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
44
|
-
if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
|
|
45
|
-
) {
|
|
46
|
-
width = 50;
|
|
47
|
-
}
|
|
48
|
-
} else if (layout !== oldLayout && ['full-width', 'wide'].indexOf(oldLayout) > -1) {
|
|
49
|
-
// 'full-width' -> 'center' or 'wide'
|
|
50
|
-
// 'wide' -> 'center' or 'full-width'
|
|
51
|
-
// unset width
|
|
52
|
-
width = undefined;
|
|
53
|
-
} else if (width) {
|
|
54
|
-
var cols = Math.round(width / 100 * gridSize);
|
|
55
|
-
var targetCols = cols;
|
|
56
|
-
if (oldLayoutIsWrapped && newLayoutIsNonWrapped) {
|
|
57
|
-
// wrap -> center needs to align to even grid
|
|
58
|
-
targetCols = Math.floor(targetCols / 2) * 2;
|
|
59
|
-
width = undefined;
|
|
60
|
-
} else if (oldLayoutIsNonWrapped && newLayoutIsWrapped) {
|
|
61
|
-
// Can be here only if
|
|
62
|
-
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
63
|
-
// AND
|
|
64
|
-
// !originalWidth || !lineLength || small image
|
|
65
|
-
// AND
|
|
66
|
-
// width defined!
|
|
67
|
-
|
|
68
|
-
// cannot resize to full column width, and cannot resize to 1 column
|
|
69
|
-
if (cols <= 1) {
|
|
70
|
-
targetCols = 2;
|
|
71
|
-
} else if (cols >= gridSize) {
|
|
72
|
-
targetCols = 10;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (targetCols !== cols) {
|
|
76
|
-
width = targetCols / gridSize * 100;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return _objectSpread(_objectSpread({}, oldAttrs), {}, {
|
|
80
|
-
layout: layout,
|
|
81
|
-
width: width
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
exports.alignAttributes = alignAttributes;
|
|
85
|
-
function calculateSnapPoints(_ref) {
|
|
86
|
-
var $pos = _ref.$pos,
|
|
87
|
-
akEditorWideLayoutWidth = _ref.akEditorWideLayoutWidth,
|
|
88
|
-
allowBreakoutSnapPoints = _ref.allowBreakoutSnapPoints,
|
|
89
|
-
containerWidth = _ref.containerWidth,
|
|
90
|
-
gridSize = _ref.gridSize,
|
|
91
|
-
gridWidth = _ref.gridWidth,
|
|
92
|
-
insideInlineLike = _ref.insideInlineLike,
|
|
93
|
-
insideLayout = _ref.insideLayout,
|
|
94
|
-
isVideoFile = _ref.isVideoFile,
|
|
95
|
-
lineLength = _ref.lineLength,
|
|
96
|
-
offsetLeft = _ref.offsetLeft,
|
|
97
|
-
wrappedLayout = _ref.wrappedLayout;
|
|
98
|
-
var snapTargets = [];
|
|
99
|
-
for (var i = 0; i < gridWidth; i++) {
|
|
100
|
-
var pxFromColumns = (0, _ui.calcPxFromColumns)(i, lineLength, gridWidth);
|
|
101
|
-
snapTargets.push(insideLayout ? pxFromColumns : pxFromColumns - offsetLeft);
|
|
102
|
-
}
|
|
103
|
-
// full width
|
|
104
|
-
snapTargets.push(lineLength - offsetLeft);
|
|
105
|
-
var columns = wrappedLayout || insideInlineLike ? 1 : 2;
|
|
106
|
-
var minimumWidth = (0, _ui.calcPxFromColumns)(columns, lineLength, gridSize);
|
|
107
|
-
var snapPoints = snapTargets.filter(function (width) {
|
|
108
|
-
return width >= minimumWidth;
|
|
109
|
-
});
|
|
110
|
-
if (!$pos) {
|
|
111
|
-
return snapPoints;
|
|
112
|
-
}
|
|
113
|
-
snapPoints = isVideoFile ? snapPoints.filter(function (width) {
|
|
114
|
-
return width > 320;
|
|
115
|
-
}) : snapPoints;
|
|
116
|
-
var isTopLevel = $pos.parent.type.name === 'doc';
|
|
117
|
-
if (isTopLevel && allowBreakoutSnapPoints) {
|
|
118
|
-
snapPoints.push(akEditorWideLayoutWidth);
|
|
119
|
-
var fullWidthPoint = containerWidth - _editorSharedStyles.akEditorBreakoutPadding;
|
|
120
|
-
if (fullWidthPoint > akEditorWideLayoutWidth) {
|
|
121
|
-
snapPoints.push(fullWidthPoint);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// EDM-1107: Ensure new snapPoints are sorted with existing points
|
|
126
|
-
snapPoints = snapPoints.sort(function (a, b) {
|
|
127
|
-
return a - b;
|
|
128
|
-
});
|
|
129
|
-
return snapPoints;
|
|
130
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../plugins/analytics';
|
|
7
|
-
import { analyticsEventKey } from '../plugins/analytics/consts';
|
|
8
|
-
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
|
9
|
-
import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from './getPerformanceOptions';
|
|
10
|
-
export const inlineNodeViewClassname = 'inlineNodeView';
|
|
11
|
-
function createNodeView({
|
|
12
|
-
nodeViewParams,
|
|
13
|
-
pmPluginFactoryParams,
|
|
14
|
-
Component,
|
|
15
|
-
extraComponentProps
|
|
16
|
-
}) {
|
|
17
|
-
// We set a variable for the current node which is
|
|
18
|
-
// used for comparisions when doing updates, before being
|
|
19
|
-
// overwritten to the updated node.
|
|
20
|
-
let currentNode = nodeViewParams.node;
|
|
21
|
-
|
|
22
|
-
// First we setup the dom element which will be rendered and "tracked" by prosemirror
|
|
23
|
-
// and also used as a "editor portal" (not react portal) target by the editor
|
|
24
|
-
// portal provider api, for rendering the Component passed.
|
|
25
|
-
|
|
26
|
-
let domRef = document.createElement('span');
|
|
27
|
-
domRef.contentEditable = 'false';
|
|
28
|
-
setDomAttrs(nodeViewParams.node, domRef);
|
|
29
|
-
|
|
30
|
-
// @see ED-3790
|
|
31
|
-
// something gets messed up during mutation processing inside of a
|
|
32
|
-
// nodeView if DOM structure has nested plain "div"s, it doesn't see the
|
|
33
|
-
// difference between them and it kills the nodeView
|
|
34
|
-
domRef.classList.add(`${nodeViewParams.node.type.name}View-content-wrap`, `${inlineNodeViewClassname}`);
|
|
35
|
-
|
|
36
|
-
// This util is shared for tracking rendering, and the ErrorBoundary that
|
|
37
|
-
// is setup to wrap the Component when rendering
|
|
38
|
-
// NOTE: This is not a prosemirror dispatch
|
|
39
|
-
function dispatchAnalyticsEvent(payload) {
|
|
40
|
-
pmPluginFactoryParams.eventDispatcher.emit(analyticsEventKey, {
|
|
41
|
-
payload
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// This is called to render the Component into domRef which is inside the
|
|
46
|
-
// prosemirror View.
|
|
47
|
-
// Internally it uses the unstable_renderSubtreeIntoContainer api to render,
|
|
48
|
-
// to the passed dom element (domRef) which means it is automatically
|
|
49
|
-
// "cleaned up" when you do a "re render".
|
|
50
|
-
function renderComponent() {
|
|
51
|
-
pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
|
|
52
|
-
dispatchAnalyticsEvent,
|
|
53
|
-
currentNode,
|
|
54
|
-
nodeViewParams,
|
|
55
|
-
Component,
|
|
56
|
-
extraComponentProps
|
|
57
|
-
}), domRef, false,
|
|
58
|
-
// node views should be rendered with intl context
|
|
59
|
-
true);
|
|
60
|
-
}
|
|
61
|
-
const {
|
|
62
|
-
samplingRate,
|
|
63
|
-
slowThreshold,
|
|
64
|
-
trackingEnabled
|
|
65
|
-
} = getPerformanceOptions(nodeViewParams.view);
|
|
66
|
-
trackingEnabled && startMeasureReactNodeViewRendered({
|
|
67
|
-
nodeTypeName: currentNode.type.name
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// We render the component while creating the node view
|
|
71
|
-
renderComponent();
|
|
72
|
-
trackingEnabled && stopMeasureReactNodeViewRendered({
|
|
73
|
-
nodeTypeName: currentNode.type.name,
|
|
74
|
-
dispatchAnalyticsEvent,
|
|
75
|
-
editorState: nodeViewParams.view.state,
|
|
76
|
-
samplingRate,
|
|
77
|
-
slowThreshold
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// https://prosemirror.net/docs/ref/#view.NodeView
|
|
81
|
-
const nodeView = {
|
|
82
|
-
get dom() {
|
|
83
|
-
return domRef;
|
|
84
|
-
},
|
|
85
|
-
update(nextNode, _decorations) {
|
|
86
|
-
// Let ProseMirror handle the update if node types are different.
|
|
87
|
-
// This prevents an issue where it was not possible to select the
|
|
88
|
-
// inline node view then replace it by entering text - the node
|
|
89
|
-
// view contents would be deleted but the node view itself would
|
|
90
|
-
// stay in the view and become uneditable.
|
|
91
|
-
if (currentNode.type !== nextNode.type) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
// On updates, we only set the new attributes if the type, attributes, and marks
|
|
95
|
-
// have changed on the node.
|
|
96
|
-
|
|
97
|
-
// NOTE: this could mean attrs changes aren't reflected in the dom,
|
|
98
|
-
// when an attribute key which was previously present is no longer
|
|
99
|
-
// present.
|
|
100
|
-
// ie.
|
|
101
|
-
// -> Original attributes { text: "hello world", color: "red" }
|
|
102
|
-
// -> Updated attributes { color: "blue" }
|
|
103
|
-
// in this case, the dom text attribute will not be cleared.
|
|
104
|
-
//
|
|
105
|
-
// This may not be an issue with any of our current node schemas.
|
|
106
|
-
if (!currentNode.sameMarkup(nextNode)) {
|
|
107
|
-
setDomAttrs(nextNode, domRef);
|
|
108
|
-
}
|
|
109
|
-
currentNode = nextNode;
|
|
110
|
-
renderComponent();
|
|
111
|
-
return true;
|
|
112
|
-
},
|
|
113
|
-
destroy() {
|
|
114
|
-
// When prosemirror destroys the node view, we need to clean up
|
|
115
|
-
// what we have previously rendered using the editor portal
|
|
116
|
-
// provider api.
|
|
117
|
-
pmPluginFactoryParams.portalProviderAPI.remove(domRef);
|
|
118
|
-
// @ts-expect-error Expect an error as domRef is expected to be
|
|
119
|
-
// of HTMLSpanElement type however once the node view has
|
|
120
|
-
// been destroyed no other consumers should still be using it.
|
|
121
|
-
domRef = undefined;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
return nodeView;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
129
|
-
* @param node The Prosemirror Node from which to source the attributes
|
|
130
|
-
*/
|
|
131
|
-
function setDomAttrs(node, element) {
|
|
132
|
-
Object.keys(node.attrs || {}).forEach(attr => {
|
|
133
|
-
element.setAttribute(attr, node.attrs[attr]);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function getPortalChildren({
|
|
137
|
-
dispatchAnalyticsEvent,
|
|
138
|
-
currentNode,
|
|
139
|
-
nodeViewParams,
|
|
140
|
-
Component,
|
|
141
|
-
extraComponentProps
|
|
142
|
-
}) {
|
|
143
|
-
return function portalChildren() {
|
|
144
|
-
var _currentNode$type$nam, _currentNode$type;
|
|
145
|
-
// All inline nodes use `display: inline` to allow for multi-line
|
|
146
|
-
// wrapping. This does produce an issue in Chrome where it is not
|
|
147
|
-
// possible to click select the position after the node,
|
|
148
|
-
// see: https://product-fabric.atlassian.net/browse/ED-12003
|
|
149
|
-
// however this is only a problem for node views that use
|
|
150
|
-
// `display: inline-block` somewhere within the Component.
|
|
151
|
-
// Looking at the below structure, spans with className
|
|
152
|
-
// `inlineNodeViewAddZeroWidthSpace` have pseudo elements that
|
|
153
|
-
// add a zero width space which fixes the problem.
|
|
154
|
-
// Without the additional zero width space before the Component,
|
|
155
|
-
// it is not possible to use the keyboard to range select in Safari.
|
|
156
|
-
//
|
|
157
|
-
// Zero width spaces on either side of the Component also prevent
|
|
158
|
-
// the cursor from appearing inside the node view on all browsers.
|
|
159
|
-
//
|
|
160
|
-
// Note:
|
|
161
|
-
// In future it is worth considering prohibiting the use of `display: inline-block`
|
|
162
|
-
// within inline node view Components however would require a sizable
|
|
163
|
-
// refactor. A test suite to catch any instances of this is ideal however
|
|
164
|
-
// the refactor required is currently out of scope for https://product-fabric.atlassian.net/browse/ED-14176
|
|
165
|
-
|
|
166
|
-
return jsx(ErrorBoundary, {
|
|
167
|
-
component: ACTION_SUBJECT.REACT_NODE_VIEW,
|
|
168
|
-
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 : ACTION_SUBJECT_ID.UNKNOWN_NODE,
|
|
169
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
170
|
-
}, jsx("span", {
|
|
171
|
-
"aria-hidden": "true",
|
|
172
|
-
className: `zeroWidthSpaceContainer`
|
|
173
|
-
}, jsx("span", {
|
|
174
|
-
className: `${inlineNodeViewClassname}AddZeroWidthSpace`
|
|
175
|
-
}), ZERO_WIDTH_SPACE), jsx(Component, _extends({
|
|
176
|
-
view: nodeViewParams.view,
|
|
177
|
-
getPos: nodeViewParams.getPos,
|
|
178
|
-
node: currentNode
|
|
179
|
-
}, extraComponentProps)), jsx("span", {
|
|
180
|
-
"aria-hidden": "true",
|
|
181
|
-
className: `${inlineNodeViewClassname}AddZeroWidthSpace`
|
|
182
|
-
}));
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
|
|
187
|
-
// The prosemirror EditorProps has a nodeViews key which has the rough shape:
|
|
188
|
-
// type nodeViews: {
|
|
189
|
-
// [nodeViewName: string]: (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
190
|
-
// }
|
|
191
|
-
// So the value of the keys on the nodeViews object, are a function which should return a NodeView.
|
|
192
|
-
// The following type NodeViewProducer, refers to these functions which return a NodeView.
|
|
193
|
-
//
|
|
194
|
-
// So the above type could also be described as
|
|
195
|
-
// type NodeViewProducer = (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
196
|
-
// nodeViews: {
|
|
197
|
-
// [nodeViewName: string]: NodeViewProducer
|
|
198
|
-
// }
|
|
199
|
-
// This return of this function is intended to be the value of a key
|
|
200
|
-
// in a ProseMirror nodeViews object.
|
|
201
|
-
export function getInlineNodeViewProducer({
|
|
202
|
-
pmPluginFactoryParams,
|
|
203
|
-
Component,
|
|
204
|
-
extraComponentProps
|
|
205
|
-
}) {
|
|
206
|
-
function nodeViewProducer(...nodeViewProducerParameters) {
|
|
207
|
-
const nodeView = createNodeView({
|
|
208
|
-
nodeViewParams: {
|
|
209
|
-
node: nodeViewProducerParameters[0],
|
|
210
|
-
view: nodeViewProducerParameters[1],
|
|
211
|
-
getPos: nodeViewProducerParameters[2],
|
|
212
|
-
decorations: nodeViewProducerParameters[3]
|
|
213
|
-
},
|
|
214
|
-
pmPluginFactoryParams,
|
|
215
|
-
Component,
|
|
216
|
-
extraComponentProps
|
|
217
|
-
});
|
|
218
|
-
return nodeView;
|
|
219
|
-
}
|
|
220
|
-
return nodeViewProducer;
|
|
221
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
-
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
3
|
-
import commonMessages from '../../messages';
|
|
4
|
-
import WrapLeftIcon from '@atlaskit/icon/glyph/editor/media-wrap-left';
|
|
5
|
-
import WrapRightIcon from '@atlaskit/icon/glyph/editor/media-wrap-right';
|
|
6
|
-
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
7
|
-
import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
8
|
-
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
9
|
-
import EditorAlignImageRight from '@atlaskit/icon/glyph/editor/align-image-right';
|
|
10
|
-
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
11
|
-
import { alignAttributes } from '../../utils/rich-media-utils';
|
|
12
|
-
import { DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
13
|
-
import { addAnalytics } from '../../plugins/analytics/utils';
|
|
14
|
-
import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, ACTION } from '../../plugins/analytics';
|
|
15
|
-
import { toolbarMessages } from './toolbar-messages';
|
|
16
|
-
import { insideTable, isInLayoutColumn } from '../../utils';
|
|
17
|
-
const alignmentIcons = [{
|
|
18
|
-
id: 'editor.media.alignLeft',
|
|
19
|
-
value: 'align-start',
|
|
20
|
-
icon: EditorAlignImageLeft
|
|
21
|
-
}, {
|
|
22
|
-
id: 'editor.media.alignCenter',
|
|
23
|
-
value: 'center',
|
|
24
|
-
icon: EditorAlignImageCenter
|
|
25
|
-
}, {
|
|
26
|
-
id: 'editor.media.alignRight',
|
|
27
|
-
value: 'align-end',
|
|
28
|
-
icon: EditorAlignImageRight
|
|
29
|
-
}];
|
|
30
|
-
const wrappingIcons = [{
|
|
31
|
-
id: 'editor.media.wrapLeft',
|
|
32
|
-
value: 'wrap-left',
|
|
33
|
-
icon: WrapLeftIcon
|
|
34
|
-
}, {
|
|
35
|
-
id: 'editor.media.wrapRight',
|
|
36
|
-
value: 'wrap-right',
|
|
37
|
-
icon: WrapRightIcon
|
|
38
|
-
}];
|
|
39
|
-
const breakoutIcons = [{
|
|
40
|
-
value: 'wide',
|
|
41
|
-
icon: WideIcon
|
|
42
|
-
}, {
|
|
43
|
-
value: 'full-width',
|
|
44
|
-
icon: FullWidthIcon
|
|
45
|
-
}];
|
|
46
|
-
const layoutToMessages = {
|
|
47
|
-
'wrap-left': toolbarMessages.wrapLeft,
|
|
48
|
-
center: commonMessages.alignImageCenter,
|
|
49
|
-
'wrap-right': toolbarMessages.wrapRight,
|
|
50
|
-
wide: commonMessages.layoutWide,
|
|
51
|
-
'full-width': commonMessages.layoutFullWidth,
|
|
52
|
-
'align-end': commonMessages.alignImageRight,
|
|
53
|
-
'align-start': commonMessages.alignImageLeft
|
|
54
|
-
};
|
|
55
|
-
const getNodeWidth = (node, schema) => {
|
|
56
|
-
const {
|
|
57
|
-
embedCard
|
|
58
|
-
} = schema.nodes;
|
|
59
|
-
if (node.type === embedCard) {
|
|
60
|
-
return node.attrs.originalWidth || DEFAULT_EMBED_CARD_WIDTH;
|
|
61
|
-
}
|
|
62
|
-
return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
|
|
63
|
-
};
|
|
64
|
-
const makeAlign = (layout, nodeType, widthPluginDependencyApi) => {
|
|
65
|
-
return (state, dispatch) => {
|
|
66
|
-
const {
|
|
67
|
-
node
|
|
68
|
-
} = state.selection;
|
|
69
|
-
const {
|
|
70
|
-
layout: previousLayoutType
|
|
71
|
-
} = node.attrs;
|
|
72
|
-
const {
|
|
73
|
-
mediaSingle
|
|
74
|
-
} = state.schema.nodes;
|
|
75
|
-
if (!dispatch) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
const widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
|
|
79
|
-
if (!node || node.type !== nodeType || !widthPluginState) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
const nodeWidth = getNodeWidth(node, state.schema);
|
|
83
|
-
const newAttrs = alignAttributes(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
|
|
84
|
-
const tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
|
|
85
|
-
tr.setMeta('scrollIntoView', false);
|
|
86
|
-
// when image captions are enabled, the wrong node gets selected after
|
|
87
|
-
// setNodeMarkup is called
|
|
88
|
-
tr.setSelection(NodeSelection.create(tr.doc, state.selection.from));
|
|
89
|
-
const {
|
|
90
|
-
doc: {
|
|
91
|
-
type: {
|
|
92
|
-
schema: {
|
|
93
|
-
nodes: {
|
|
94
|
-
paragraph
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
} = tr;
|
|
100
|
-
|
|
101
|
-
// see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
|
|
102
|
-
if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && (insideTable(state) || isInLayoutColumn(state))) {
|
|
103
|
-
tr.insert(state.selection.to, paragraph.createAndFill());
|
|
104
|
-
}
|
|
105
|
-
dispatch(addAnalytics(state, tr, {
|
|
106
|
-
eventType: EVENT_TYPE.TRACK,
|
|
107
|
-
action: ACTION.SELECTED,
|
|
108
|
-
actionSubject: ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
|
|
109
|
-
actionSubjectId: ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
|
|
110
|
-
attributes: {
|
|
111
|
-
previousLayoutType,
|
|
112
|
-
currentLayoutType: layout
|
|
113
|
-
}
|
|
114
|
-
}));
|
|
115
|
-
return true;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
const mapIconsToToolbarItem = (icons, layout, intl, nodeType, widthPluginDependencyApi) => icons.map(toolbarItem => {
|
|
119
|
-
const {
|
|
120
|
-
id,
|
|
121
|
-
value
|
|
122
|
-
} = toolbarItem;
|
|
123
|
-
return {
|
|
124
|
-
id: id,
|
|
125
|
-
type: 'button',
|
|
126
|
-
icon: toolbarItem.icon,
|
|
127
|
-
title: intl.formatMessage(layoutToMessages[value]),
|
|
128
|
-
selected: layout === value,
|
|
129
|
-
onClick: makeAlign(value, nodeType, widthPluginDependencyApi)
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
const shouldHideLayoutToolbar = (selection, {
|
|
133
|
-
nodes
|
|
134
|
-
}, allowResizingInTables) => {
|
|
135
|
-
return hasParentNodeOfType([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand, ...(allowResizingInTables ? [] : [nodes.table])].filter(Boolean))(selection);
|
|
136
|
-
};
|
|
137
|
-
const buildLayoutButtons = (state, intl, nodeType, widthPluginDependencyApi, allowResizing, allowResizingInTables, allowWrapping = true, allowAlignment = true) => {
|
|
138
|
-
const {
|
|
139
|
-
selection
|
|
140
|
-
} = state;
|
|
141
|
-
if (!(selection instanceof NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
|
|
142
|
-
return [];
|
|
143
|
-
}
|
|
144
|
-
const {
|
|
145
|
-
layout
|
|
146
|
-
} = selection.node.attrs;
|
|
147
|
-
const alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
148
|
-
const wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
149
|
-
const breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
150
|
-
const items = [...alignmentToolbarItems, ...getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping), ...wrappingToolbarItems, ...getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing), ...breakOutToolbarItems];
|
|
151
|
-
return items;
|
|
152
|
-
};
|
|
153
|
-
const getSeparatorBetweenAlignmentAndWrapping = (allowAlignment, allowWrapping) => allowAlignment && allowWrapping ? [{
|
|
154
|
-
type: 'separator'
|
|
155
|
-
}] : [];
|
|
156
|
-
const getSeparatorBeforeBreakoutItems = (allowAlignment, allowWrapping, allowResizing) => !allowResizing && (allowAlignment || allowWrapping) ? [{
|
|
157
|
-
type: 'separator'
|
|
158
|
-
}] : [];
|
|
159
|
-
export default buildLayoutButtons;
|