@atlaskit/editor-core 150.0.2 → 151.1.1
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 +69 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +8 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-bidi-warning/index.js +25 -0
- package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +11 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +43 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +118 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +12 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +5 -0
- package/dist/cjs/plugins/code-block/index.js +10 -6
- package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/cjs/plugins/code-block/pm-plugins/main.js +12 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +9 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/index.js +8 -0
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +9 -3
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-bidi-warning/index.js +15 -0
- package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +31 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +88 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/es2019/plugins/code-block/index.js +6 -1
- package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +16 -4
- package/dist/es2019/plugins/code-block/pm-plugins/main.js +50 -39
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/index.js +2 -1
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +9 -3
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-bidi-warning/index.js +17 -0
- package/dist/esm/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +30 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +96 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/esm/plugins/code-block/index.js +10 -6
- package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/esm/plugins/code-block/pm-plugins/main.js +11 -3
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/index.js +2 -1
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +7 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +5 -0
- package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +11 -2
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +5 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/HyperlinkToolbarAppearance.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +17 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +21 -18
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
-
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
|
|
11
|
-
var _docBuilder = require("@atlaskit/editor-test-helpers/doc-builder");
|
|
12
|
-
|
|
13
|
-
var _mediaTestHelpers = require("@atlaskit/media-test-helpers");
|
|
14
|
-
|
|
15
|
-
var _createProsemirrorEditor = require("@atlaskit/editor-test-helpers/create-prosemirror-editor");
|
|
16
|
-
|
|
17
|
-
var _sendKeyToPm = _interopRequireDefault(require("@atlaskit/editor-test-helpers/send-key-to-pm"));
|
|
18
|
-
|
|
19
|
-
var _editorCommon = require("@atlaskit/editor-common");
|
|
20
|
-
|
|
21
|
-
var _hyperlink = _interopRequireDefault(require("../../hyperlink"));
|
|
22
|
-
|
|
23
|
-
var _ = _interopRequireDefault(require("../"));
|
|
24
|
-
|
|
25
|
-
var _actions = require("../pm-plugins/linking/actions");
|
|
26
|
-
|
|
27
|
-
var _checkMediaType = require("../utils/check-media-type");
|
|
28
|
-
|
|
29
|
-
var _linking = require("../pm-plugins/linking");
|
|
30
|
-
|
|
31
|
-
var linking = _interopRequireWildcard(require("./linking"));
|
|
32
|
-
|
|
33
|
-
var _types = require("../../analytics/types");
|
|
34
|
-
|
|
35
|
-
var analyticUtils = _interopRequireWildcard(require("../../analytics/utils"));
|
|
36
|
-
|
|
37
|
-
var commands = _interopRequireWildcard(require("../../../commands"));
|
|
38
|
-
|
|
39
|
-
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); }
|
|
40
|
-
|
|
41
|
-
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; }
|
|
42
|
-
|
|
43
|
-
var setUrlToMedia = linking.setUrlToMedia,
|
|
44
|
-
showLinkingToolbarWithMediaTypeCheck = linking.showLinkingToolbarWithMediaTypeCheck,
|
|
45
|
-
unlink = linking.unlink;
|
|
46
|
-
jest.mock('../utils/check-media-type', function () {
|
|
47
|
-
return {
|
|
48
|
-
checkMediaType: jest.fn()
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
describe('image linking', function () {
|
|
52
|
-
var createEditor = (0, _createProsemirrorEditor.createProsemirrorEditorFactory)();
|
|
53
|
-
var preset = new _createProsemirrorEditor.Preset();
|
|
54
|
-
var mediaProvider = Promise.resolve({
|
|
55
|
-
viewMediaClientConfig: (0, _mediaTestHelpers.getDefaultMediaClientConfig)()
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
var providerFactory = _editorCommon.ProviderFactory.create({
|
|
59
|
-
mediaProvider: mediaProvider
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
preset.add([_.default, {
|
|
63
|
-
allowMediaSingle: true,
|
|
64
|
-
allowLinking: true
|
|
65
|
-
}]).add(_hyperlink.default);
|
|
66
|
-
|
|
67
|
-
var editor = function editor(doc) {
|
|
68
|
-
return createEditor({
|
|
69
|
-
doc: doc,
|
|
70
|
-
preset: preset,
|
|
71
|
-
providerFactory: providerFactory
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
var document = (0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
76
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
77
|
-
type: 'file',
|
|
78
|
-
collection: 'MediaServicesSample'
|
|
79
|
-
})()), (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
80
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
81
|
-
type: 'file',
|
|
82
|
-
collection: 'MediaServicesSample'
|
|
83
|
-
})()));
|
|
84
|
-
var mockDispatch = jest.fn();
|
|
85
|
-
afterEach(function () {
|
|
86
|
-
mockDispatch.mockClear();
|
|
87
|
-
});
|
|
88
|
-
describe('analytics', function () {
|
|
89
|
-
var FIRST_CALL = 0;
|
|
90
|
-
var ANALYTIC_PAYLOAD = 2;
|
|
91
|
-
var analyticUtilsSpy = jest.spyOn(analyticUtils, 'addAnalytics');
|
|
92
|
-
beforeEach(function () {
|
|
93
|
-
analyticUtilsSpy.mockReset();
|
|
94
|
-
});
|
|
95
|
-
afterAll(function () {
|
|
96
|
-
jest.resetAllMocks();
|
|
97
|
-
});
|
|
98
|
-
it('should call analytic when creating a link', function () {
|
|
99
|
-
var _editor = editor(document),
|
|
100
|
-
editorView = _editor.editorView;
|
|
101
|
-
|
|
102
|
-
setUrlToMedia('http://google.com', _types.INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
103
|
-
expect(analyticUtilsSpy).toBeCalled();
|
|
104
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
105
|
-
action: 'added',
|
|
106
|
-
actionSubject: 'media',
|
|
107
|
-
actionSubjectId: 'link',
|
|
108
|
-
attributes: expect.objectContaining({
|
|
109
|
-
inputMethod: 'manual'
|
|
110
|
-
}),
|
|
111
|
-
eventType: 'track'
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('existing links', function () {
|
|
115
|
-
var googleUrl = 'http://google.com';
|
|
116
|
-
var documentWithMediaWithLink = (0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.a)({
|
|
117
|
-
href: googleUrl
|
|
118
|
-
})((0, _docBuilder.media)({
|
|
119
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
120
|
-
type: 'file',
|
|
121
|
-
collection: 'MediaServicesSample'
|
|
122
|
-
})())));
|
|
123
|
-
it('should add edit analytic when modifying link', function () {
|
|
124
|
-
var _editor2 = editor(documentWithMediaWithLink),
|
|
125
|
-
editorView = _editor2.editorView;
|
|
126
|
-
|
|
127
|
-
setUrlToMedia('http://random-url.com', _types.INPUT_METHOD.MANUAL)(editorView.state, editorView.dispatch, editorView);
|
|
128
|
-
expect(analyticUtilsSpy).toHaveBeenCalledTimes(1);
|
|
129
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
130
|
-
action: 'edited',
|
|
131
|
-
actionSubject: 'media',
|
|
132
|
-
actionSubjectId: 'link',
|
|
133
|
-
eventType: 'track'
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
it('should delete analytic when removing a link', function () {
|
|
137
|
-
var _editor3 = editor(documentWithMediaWithLink),
|
|
138
|
-
editorView = _editor3.editorView;
|
|
139
|
-
|
|
140
|
-
unlink(editorView.state, editorView.dispatch, editorView);
|
|
141
|
-
expect(analyticUtilsSpy).toBeCalledTimes(1);
|
|
142
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
143
|
-
action: 'deleted',
|
|
144
|
-
actionSubject: 'media',
|
|
145
|
-
actionSubjectId: 'link',
|
|
146
|
-
eventType: 'track'
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
it("shouldn't call an analytic if the url was modified to the same url", function () {
|
|
150
|
-
var _editor4 = editor(documentWithMediaWithLink),
|
|
151
|
-
editorView = _editor4.editorView;
|
|
152
|
-
|
|
153
|
-
setUrlToMedia(googleUrl, _types.INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
154
|
-
expect(analyticUtilsSpy).not.toBeCalled();
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
describe('errors', function () {
|
|
158
|
-
beforeAll(function () {
|
|
159
|
-
jest.spyOn(commands, 'createToggleBlockMarkOnRange').mockImplementation(function () {
|
|
160
|
-
throw new Error('This error should be caught');
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
it("should call analytic if there's an error creating a link", function () {
|
|
164
|
-
var _editor5 = editor(document),
|
|
165
|
-
editorView = _editor5.editorView;
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
setUrlToMedia('http://google.com', _types.INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
169
|
-
} catch (e) {// noop
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
173
|
-
action: 'errored',
|
|
174
|
-
actionSubject: 'media',
|
|
175
|
-
actionSubjectId: 'link',
|
|
176
|
-
attributes: {
|
|
177
|
-
action: 'added'
|
|
178
|
-
},
|
|
179
|
-
eventType: 'track'
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe('show linking toolbar', function () {
|
|
185
|
-
describe('selected media is an image', function () {
|
|
186
|
-
beforeAll(function () {
|
|
187
|
-
_checkMediaType.checkMediaType.mockReturnValue(Promise.resolve('image'));
|
|
188
|
-
});
|
|
189
|
-
it('call dispatch with correct param with a media is selected', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
190
|
-
var _editor6, editorView, result, expectTransaction;
|
|
191
|
-
|
|
192
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
193
|
-
while (1) {
|
|
194
|
-
switch (_context.prev = _context.next) {
|
|
195
|
-
case 0:
|
|
196
|
-
_editor6 = editor(document), editorView = _editor6.editorView;
|
|
197
|
-
_context.next = 3;
|
|
198
|
-
return (0, _mediaTestHelpers.flushPromises)();
|
|
199
|
-
|
|
200
|
-
case 3:
|
|
201
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
202
|
-
expectTransaction = editorView.state.tr.setMeta(_linking.mediaLinkingPluginKey, {
|
|
203
|
-
type: _actions.MediaLinkingActionsTypes.showToolbar
|
|
204
|
-
});
|
|
205
|
-
_context.next = 7;
|
|
206
|
-
return (0, _mediaTestHelpers.flushPromises)();
|
|
207
|
-
|
|
208
|
-
case 7:
|
|
209
|
-
expect(result).toEqual(true);
|
|
210
|
-
expect(mockDispatch).toHaveBeenCalledWith(expectTransaction);
|
|
211
|
-
|
|
212
|
-
case 9:
|
|
213
|
-
case "end":
|
|
214
|
-
return _context.stop();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}, _callee);
|
|
218
|
-
})));
|
|
219
|
-
it('does not call dispatch when selection is not a media single node', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
220
|
-
var _editor7, editorView, result;
|
|
221
|
-
|
|
222
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
223
|
-
while (1) {
|
|
224
|
-
switch (_context2.prev = _context2.next) {
|
|
225
|
-
case 0:
|
|
226
|
-
_editor7 = editor(document), editorView = _editor7.editorView;
|
|
227
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
228
|
-
_context2.next = 4;
|
|
229
|
-
return (0, _mediaTestHelpers.flushPromises)();
|
|
230
|
-
|
|
231
|
-
case 4:
|
|
232
|
-
expect(result).toEqual(false);
|
|
233
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
234
|
-
|
|
235
|
-
case 6:
|
|
236
|
-
case "end":
|
|
237
|
-
return _context2.stop();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}, _callee2);
|
|
241
|
-
})));
|
|
242
|
-
it('does not call dispatch when selection has changed', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
243
|
-
var _editor8, editorView, result;
|
|
244
|
-
|
|
245
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
246
|
-
while (1) {
|
|
247
|
-
switch (_context3.prev = _context3.next) {
|
|
248
|
-
case 0:
|
|
249
|
-
_editor8 = editor(document), editorView = _editor8.editorView;
|
|
250
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
251
|
-
(0, _sendKeyToPm.default)(editorView, 'ArrowDown');
|
|
252
|
-
_context3.next = 5;
|
|
253
|
-
return (0, _mediaTestHelpers.flushPromises)();
|
|
254
|
-
|
|
255
|
-
case 5:
|
|
256
|
-
expect(result).toEqual(false);
|
|
257
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
258
|
-
|
|
259
|
-
case 7:
|
|
260
|
-
case "end":
|
|
261
|
-
return _context3.stop();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}, _callee3);
|
|
265
|
-
})));
|
|
266
|
-
});
|
|
267
|
-
describe('selected media is a video', function () {
|
|
268
|
-
beforeAll(function () {
|
|
269
|
-
_checkMediaType.checkMediaType.mockReturnValue(Promise.resolve('video'));
|
|
270
|
-
});
|
|
271
|
-
it('does not call dispatch', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
272
|
-
var _editor9, editorView, result;
|
|
273
|
-
|
|
274
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
275
|
-
while (1) {
|
|
276
|
-
switch (_context4.prev = _context4.next) {
|
|
277
|
-
case 0:
|
|
278
|
-
_editor9 = editor(document), editorView = _editor9.editorView;
|
|
279
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
280
|
-
_context4.next = 4;
|
|
281
|
-
return (0, _mediaTestHelpers.flushPromises)();
|
|
282
|
-
|
|
283
|
-
case 4:
|
|
284
|
-
expect(result).toEqual(false);
|
|
285
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
286
|
-
|
|
287
|
-
case 6:
|
|
288
|
-
case "end":
|
|
289
|
-
return _context4.stop();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}, _callee4);
|
|
293
|
-
})));
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
|
-
var _reactIntl = require("react-intl");
|
|
10
|
-
|
|
11
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
-
|
|
13
|
-
var _messages = require("./messages");
|
|
14
|
-
|
|
15
|
-
var _index = _interopRequireDefault(require("./index"));
|
|
16
|
-
|
|
17
|
-
var renderWithIntl = function renderWithIntl(component) {
|
|
18
|
-
return (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
|
|
19
|
-
locale: "en"
|
|
20
|
-
}, component));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
var onClick = function onClick() {};
|
|
24
|
-
|
|
25
|
-
describe('CaptionComponent', function () {
|
|
26
|
-
it('should show a placeholder by default', function () {
|
|
27
|
-
var _renderWithIntl = renderWithIntl( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
28
|
-
onClick: onClick
|
|
29
|
-
})),
|
|
30
|
-
getByText = _renderWithIntl.getByText;
|
|
31
|
-
|
|
32
|
-
expect(getByText(_messages.messages.placeholder.defaultMessage)).not.toBeNull();
|
|
33
|
-
});
|
|
34
|
-
it('should have the placeholder colour as N200', function () {
|
|
35
|
-
var _renderWithIntl2 = renderWithIntl( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
36
|
-
onClick: onClick
|
|
37
|
-
})),
|
|
38
|
-
container = _renderWithIntl2.container;
|
|
39
|
-
|
|
40
|
-
expect(container.firstChild).toHaveStyle("color: ".concat(_colors.N200));
|
|
41
|
-
});
|
|
42
|
-
it('placeholder should be centered', function () {
|
|
43
|
-
var _renderWithIntl3 = renderWithIntl( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
44
|
-
onClick: onClick
|
|
45
|
-
})),
|
|
46
|
-
container = _renderWithIntl3.container;
|
|
47
|
-
|
|
48
|
-
expect(container.firstChild).toHaveStyle("text-align: center");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
var _schema = _interopRequireDefault(require("@atlaskit/editor-test-helpers/schema"));
|
|
8
|
-
|
|
9
|
-
var _editorCommon = require("@atlaskit/editor-common");
|
|
10
|
-
|
|
11
|
-
var _getTestEmojiResource = require("@atlaskit/util-data-test/get-test-emoji-resource");
|
|
12
|
-
|
|
13
|
-
var _toolbar = require("./toolbar");
|
|
14
|
-
|
|
15
|
-
var actions = _interopRequireWildcard(require("../panel/actions"));
|
|
16
|
-
|
|
17
|
-
var _Palettes = require("../../ui/ColorPalette/Palettes");
|
|
18
|
-
|
|
19
|
-
var _createProsemirrorEditor = require("@atlaskit/editor-test-helpers/create-prosemirror-editor");
|
|
20
|
-
|
|
21
|
-
var _ = _interopRequireDefault(require("."));
|
|
22
|
-
|
|
23
|
-
var _docBuilder = require("@atlaskit/editor-test-helpers/doc-builder");
|
|
24
|
-
|
|
25
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
26
|
-
|
|
27
|
-
var _analytics = _interopRequireWildcard(require("../analytics"));
|
|
28
|
-
|
|
29
|
-
var _emoji = require("../emoji");
|
|
30
|
-
|
|
31
|
-
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); }
|
|
32
|
-
|
|
33
|
-
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; }
|
|
34
|
-
|
|
35
|
-
var dummyFormatMessage = function dummyFormatMessage(messageDescriptor) {
|
|
36
|
-
return messageDescriptor.defaultMessage || '';
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var changePanelTypespy = jest.spyOn(actions, 'changePanelType');
|
|
40
|
-
describe('getToolbarItems', function () {
|
|
41
|
-
var providerFactory = new _editorCommon.ProviderFactory();
|
|
42
|
-
providerFactory.setProvider('emojiProvider', Promise.resolve((0, _getTestEmojiResource.getTestEmojiResource)()));
|
|
43
|
-
var panelPreset = new _createProsemirrorEditor.Preset().add([_.default, {
|
|
44
|
-
UNSAFE_allowCustomPanel: true
|
|
45
|
-
}]);
|
|
46
|
-
var itemsWithCustomPanelEnabled = (0, _toolbar.getToolbarItems)(dummyFormatMessage, _schema.default.nodes.panel, true, providerFactory, _adfSchema.PanelType.INFO);
|
|
47
|
-
afterEach(function () {
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
});
|
|
50
|
-
it('should return 7 items when isCustomPanelEnabled is false', function () {
|
|
51
|
-
var items = (0, _toolbar.getToolbarItems)(dummyFormatMessage, _schema.default.nodes.panel, false, providerFactory);
|
|
52
|
-
expect(items).toHaveLength(7);
|
|
53
|
-
});
|
|
54
|
-
describe('if isCustomPanelEnabled is true', function () {
|
|
55
|
-
it('should return 11 items', function () {
|
|
56
|
-
expect(itemsWithCustomPanelEnabled).toHaveLength(11);
|
|
57
|
-
});
|
|
58
|
-
it('should contain emoji and color picker button', function () {
|
|
59
|
-
var emojiButton = itemsWithCustomPanelEnabled.find(function (item) {
|
|
60
|
-
return item.type === 'select' && item.selectType === 'emoji';
|
|
61
|
-
});
|
|
62
|
-
var colorButton = itemsWithCustomPanelEnabled.find(function (item) {
|
|
63
|
-
return item.type === 'select' && item.selectType === 'color';
|
|
64
|
-
});
|
|
65
|
-
expect(emojiButton).not.toBeUndefined();
|
|
66
|
-
expect(colorButton).not.toBeUndefined();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('custom panel toolbar items', function () {
|
|
70
|
-
var createEditor = (0, _createProsemirrorEditor.createProsemirrorEditorFactory)();
|
|
71
|
-
|
|
72
|
-
var _createEditor = createEditor({
|
|
73
|
-
doc: (0, _docBuilder.doc)((0, _docBuilder.panel)({
|
|
74
|
-
panelType: 'info'
|
|
75
|
-
})((0, _docBuilder.p)('{<>}'))),
|
|
76
|
-
preset: panelPreset,
|
|
77
|
-
providerFactory: providerFactory
|
|
78
|
-
}),
|
|
79
|
-
editorView = _createEditor.editorView;
|
|
80
|
-
|
|
81
|
-
it("should call changePanelType when clicked on emoji picker\n with changed emoji", function () {
|
|
82
|
-
var emojiPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
83
|
-
return item.type === 'select' && item.selectType === 'emoji';
|
|
84
|
-
});
|
|
85
|
-
emojiPickerConfig.onChange(':smiley:')(editorView.state);
|
|
86
|
-
expect(changePanelTypespy).toBeCalledWith(_adfSchema.PanelType.CUSTOM, {
|
|
87
|
-
emoji: ':smiley:'
|
|
88
|
-
}, true);
|
|
89
|
-
});
|
|
90
|
-
it("should call changePanelType when clicked on color picker\n with changed color", function () {
|
|
91
|
-
var colorPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
92
|
-
return item.type === 'select' && item.selectType === 'color';
|
|
93
|
-
});
|
|
94
|
-
colorPickerConfig.onChange({
|
|
95
|
-
label: 'Mintie',
|
|
96
|
-
value: '#ABF5D1',
|
|
97
|
-
border: _Palettes.DEFAULT_BORDER_COLOR
|
|
98
|
-
})(editorView.state);
|
|
99
|
-
expect(changePanelTypespy).toBeCalledWith(_adfSchema.PanelType.CUSTOM, {
|
|
100
|
-
color: '#ABF5D1'
|
|
101
|
-
}, true);
|
|
102
|
-
});
|
|
103
|
-
it("should call changePanelType when clicked on remove emoji", function () {
|
|
104
|
-
var removeEmojiButton = itemsWithCustomPanelEnabled.find(function (item) {
|
|
105
|
-
return item.type === 'button' && item.id === 'editor.panel.removeEmoji';
|
|
106
|
-
});
|
|
107
|
-
removeEmojiButton.onClick(editorView.state);
|
|
108
|
-
expect(changePanelTypespy).toBeCalledWith(_adfSchema.PanelType.CUSTOM, {
|
|
109
|
-
emoji: undefined
|
|
110
|
-
}, true);
|
|
111
|
-
});
|
|
112
|
-
it("should not call changePanelType when clicked on remove emoji when no emoji in panel", function () {
|
|
113
|
-
var _createEditor2 = createEditor({
|
|
114
|
-
doc: (0, _docBuilder.doc)((0, _docBuilder.panel)({
|
|
115
|
-
panelType: 'custom'
|
|
116
|
-
})((0, _docBuilder.p)('{<>}'))),
|
|
117
|
-
preset: panelPreset,
|
|
118
|
-
providerFactory: providerFactory
|
|
119
|
-
}),
|
|
120
|
-
editorView = _createEditor2.editorView;
|
|
121
|
-
|
|
122
|
-
var toolbarItems = (0, _toolbar.getToolbarItems)(dummyFormatMessage, _schema.default.nodes.panel, true, providerFactory, _adfSchema.PanelType.CUSTOM);
|
|
123
|
-
var removeEmojiButton = toolbarItems.find(function (item) {
|
|
124
|
-
return item.type === 'button' && item.id === 'editor.panel.removeEmoji';
|
|
125
|
-
});
|
|
126
|
-
changePanelTypespy.mockClear();
|
|
127
|
-
removeEmojiButton.onClick(editorView.state);
|
|
128
|
-
expect(changePanelTypespy).not.toBeCalled();
|
|
129
|
-
});
|
|
130
|
-
it("should have remove emoji button disabled when focus on panel without emoji", function () {
|
|
131
|
-
var toolbarItems = (0, _toolbar.getToolbarItems)(dummyFormatMessage, _schema.default.nodes.panel, true, providerFactory, _adfSchema.PanelType.CUSTOM, '#ABF5D1', '');
|
|
132
|
-
var removeEmojiButton = toolbarItems.find(function (item) {
|
|
133
|
-
return item.type === 'button' && item.id === 'editor.panel.removeEmoji';
|
|
134
|
-
});
|
|
135
|
-
expect(removeEmojiButton.disabled).toBe(true);
|
|
136
|
-
});
|
|
137
|
-
it("should have remove emoji button enabled when focus on panel with emoji", function () {
|
|
138
|
-
var toolbarItems = (0, _toolbar.getToolbarItems)(dummyFormatMessage, _schema.default.nodes.panel, true, providerFactory, _adfSchema.PanelType.CUSTOM, '#ABF5D1', ':smiley:');
|
|
139
|
-
var removeEmojiButton = toolbarItems.find(function (item) {
|
|
140
|
-
return item.type === 'button' && item.id === 'editor.panel.removeEmoji';
|
|
141
|
-
});
|
|
142
|
-
expect(removeEmojiButton.disabled).toBe(false);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('analytics for custom panels', function () {
|
|
146
|
-
var createEditor = (0, _createProsemirrorEditor.createProsemirrorEditorFactory)();
|
|
147
|
-
var createAnalyticsEvent = jest.fn(function () {
|
|
148
|
-
return {
|
|
149
|
-
fire: function fire() {}
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
var editorView;
|
|
153
|
-
beforeEach(function () {
|
|
154
|
-
var _createEditor3 = createEditor({
|
|
155
|
-
doc: (0, _docBuilder.doc)((0, _docBuilder.panel)({
|
|
156
|
-
panelType: 'info'
|
|
157
|
-
})((0, _docBuilder.p)('{<>}'))),
|
|
158
|
-
preset: panelPreset.add([_analytics.default, {
|
|
159
|
-
createAnalyticsEvent: createAnalyticsEvent
|
|
160
|
-
}]),
|
|
161
|
-
providerFactory: providerFactory,
|
|
162
|
-
pluginKey: _emoji.emojiPluginKey
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
editorView = _createEditor3.editorView;
|
|
166
|
-
});
|
|
167
|
-
it('Should trigger analytics when background color is changed', function () {
|
|
168
|
-
var colorPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
169
|
-
return item.type === 'select' && item.selectType === 'color';
|
|
170
|
-
});
|
|
171
|
-
colorPickerConfig.onChange({
|
|
172
|
-
label: 'Mintie',
|
|
173
|
-
value: '#ABF5D1',
|
|
174
|
-
border: _Palettes.DEFAULT_BORDER_COLOR
|
|
175
|
-
})(editorView.state, editorView.dispatch);
|
|
176
|
-
var payload = {
|
|
177
|
-
action: _analytics.ACTION.CHANGED_BACKGROUND_COLOR,
|
|
178
|
-
actionSubject: _analytics.ACTION_SUBJECT.PANEL,
|
|
179
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
180
|
-
attributes: expect.objectContaining({
|
|
181
|
-
newColor: '#ABF5D1',
|
|
182
|
-
previousColor: '#DEEBFF'
|
|
183
|
-
}),
|
|
184
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
185
|
-
};
|
|
186
|
-
expect(createAnalyticsEvent).toHaveBeenCalledWith(payload);
|
|
187
|
-
});
|
|
188
|
-
it('Should trigger analytics when Icon is changed', function () {
|
|
189
|
-
var emojiPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
190
|
-
return item.type === 'select' && item.selectType === 'emoji';
|
|
191
|
-
});
|
|
192
|
-
emojiPickerConfig.onChange(':smiley:')(editorView.state, editorView.dispatch);
|
|
193
|
-
var payload = {
|
|
194
|
-
action: _analytics.ACTION.CHANGED_ICON,
|
|
195
|
-
actionSubject: _analytics.ACTION_SUBJECT.PANEL,
|
|
196
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
197
|
-
attributes: expect.objectContaining({
|
|
198
|
-
newIcon: ':smiley:',
|
|
199
|
-
previousIcon: ''
|
|
200
|
-
}),
|
|
201
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
202
|
-
};
|
|
203
|
-
expect(createAnalyticsEvent).toHaveBeenCalledWith(payload);
|
|
204
|
-
});
|
|
205
|
-
it('Should trigger analytics when Icon is removed', function () {
|
|
206
|
-
var removeEmojiButton = itemsWithCustomPanelEnabled.find(function (item) {
|
|
207
|
-
return item.type === 'button' && item.id === 'editor.panel.removeEmoji';
|
|
208
|
-
});
|
|
209
|
-
var emojiPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
210
|
-
return item.type === 'select' && item.selectType === 'emoji';
|
|
211
|
-
});
|
|
212
|
-
emojiPickerConfig.onChange(':smiley:')(editorView.state, editorView.dispatch);
|
|
213
|
-
removeEmojiButton.onClick(editorView.state, editorView.dispatch);
|
|
214
|
-
var payload = {
|
|
215
|
-
action: _analytics.ACTION.REMOVE_ICON,
|
|
216
|
-
actionSubject: _analytics.ACTION_SUBJECT.PANEL,
|
|
217
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
218
|
-
attributes: expect.objectContaining({
|
|
219
|
-
icon: ':smiley:'
|
|
220
|
-
}),
|
|
221
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
222
|
-
};
|
|
223
|
-
expect(createAnalyticsEvent).nthCalledWith(4, payload);
|
|
224
|
-
});
|
|
225
|
-
it('Should not fire analytics when the same background color is selected', function () {
|
|
226
|
-
var colorPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
227
|
-
return item.type === 'select' && item.selectType === 'color';
|
|
228
|
-
});
|
|
229
|
-
colorPickerConfig.onChange({
|
|
230
|
-
label: 'Mintie',
|
|
231
|
-
value: '#ABF5D1',
|
|
232
|
-
border: _Palettes.DEFAULT_BORDER_COLOR
|
|
233
|
-
})(editorView.state, editorView.dispatch);
|
|
234
|
-
colorPickerConfig.onChange({
|
|
235
|
-
label: 'Mintie',
|
|
236
|
-
value: '#ABF5D1',
|
|
237
|
-
border: _Palettes.DEFAULT_BORDER_COLOR
|
|
238
|
-
})(editorView.state, editorView.dispatch);
|
|
239
|
-
expect(createAnalyticsEvent).toHaveBeenCalledTimes(3);
|
|
240
|
-
});
|
|
241
|
-
it('Should not fire analtyics when same emoji is selected', function () {
|
|
242
|
-
var emojiPickerConfig = itemsWithCustomPanelEnabled.find(function (item) {
|
|
243
|
-
return item.type === 'select' && item.selectType === 'emoji';
|
|
244
|
-
});
|
|
245
|
-
emojiPickerConfig.onChange(':smiley:')(editorView.state, editorView.dispatch);
|
|
246
|
-
emojiPickerConfig.onChange(':smiley:')(editorView.state, editorView.dispatch);
|
|
247
|
-
expect(createAnalyticsEvent).toHaveBeenCalledTimes(3);
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
});
|