@atlaskit/editor-core 150.0.0 → 151.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -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 +4 -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-block/toolbar.js +1 -1
- package/dist/cjs/plugins/collab-edit/ui/to-avatar.js +4 -8
- 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 +8 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- 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/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/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- 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 +4 -2
- 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-block/toolbar.js +1 -1
- package/dist/es2019/plugins/collab-edit/ui/to-avatar.js +2 -6
- 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 +8 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- 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/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/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- 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 +4 -2
- 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-block/toolbar.js +1 -1
- package/dist/esm/plugins/collab-edit/ui/to-avatar.js +4 -8
- 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 +8 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- 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/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/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- 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 +3 -1
- package/dist/types/plugins/analytics/analytics-queue.d.ts +1 -1
- 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/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -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/utils.d.ts +0 -21
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- 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/plugins/quick-insert/index.d.ts +1 -1
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +8 -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 +20 -17
- 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,85 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mountWithIntl } from '@atlaskit/editor-test-helpers/enzyme';
|
|
3
|
-
import { createProsemirrorEditorFactory, Preset } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
4
|
-
import { doc, p, panel } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
5
|
-
import { EmojiPickerButton } from './EmojiPickerButton';
|
|
6
|
-
import panelPlugin from '../../panel';
|
|
7
|
-
import { ProviderFactory } from '@atlaskit/editor-common';
|
|
8
|
-
import { getTestEmojiResource } from '@atlaskit/util-data-test/get-test-emoji-resource';
|
|
9
|
-
import { act } from 'react-dom/test-utils';
|
|
10
|
-
describe('emoji-picker-button', function () {
|
|
11
|
-
var createEditor = createProsemirrorEditorFactory();
|
|
12
|
-
var wrapper;
|
|
13
|
-
var onChangeMock;
|
|
14
|
-
var providerFactory = new ProviderFactory();
|
|
15
|
-
var panelPreset = new Preset().add([panelPlugin, {
|
|
16
|
-
UNSAFE_allowCustomPanel: true
|
|
17
|
-
}]);
|
|
18
|
-
beforeEach(function () {
|
|
19
|
-
var _createEditor = createEditor({
|
|
20
|
-
doc: doc(panel({
|
|
21
|
-
panelType: 'info'
|
|
22
|
-
})(p('{<>}'))),
|
|
23
|
-
preset: panelPreset,
|
|
24
|
-
providerFactory: providerFactory
|
|
25
|
-
}),
|
|
26
|
-
editorView = _createEditor.editorView;
|
|
27
|
-
|
|
28
|
-
providerFactory.setProvider('emojiProvider', Promise.resolve(getTestEmojiResource()));
|
|
29
|
-
onChangeMock = jest.fn();
|
|
30
|
-
wrapper = mountWithIntl( /*#__PURE__*/React.createElement(EmojiPickerButton, {
|
|
31
|
-
view: editorView,
|
|
32
|
-
providerFactory: providerFactory,
|
|
33
|
-
onChange: onChangeMock
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
36
|
-
afterEach(function () {
|
|
37
|
-
providerFactory.removeProvider('emojiProvider');
|
|
38
|
-
wrapper && wrapper.unmount();
|
|
39
|
-
});
|
|
40
|
-
it('should render a button', function () {
|
|
41
|
-
expect(wrapper.find('button')).toHaveLength(1); // ensure no popup is rendered
|
|
42
|
-
|
|
43
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
44
|
-
});
|
|
45
|
-
it('should show a EmojiPicker popup after clicking button', function () {
|
|
46
|
-
// popup still not shown before the click
|
|
47
|
-
wrapper.find('button').simulate('click'); // show the popup
|
|
48
|
-
|
|
49
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
50
|
-
});
|
|
51
|
-
it('should close EmojiPicker popup after clicking outside', function () {
|
|
52
|
-
// clicking on the button to open the popup
|
|
53
|
-
wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
|
|
54
|
-
|
|
55
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
56
|
-
var emojiPicker = wrapper.find('EmojiPickerInternal').instance(); // calling click outside
|
|
57
|
-
|
|
58
|
-
act(function () {
|
|
59
|
-
emojiPicker.props.handleClickOutside();
|
|
60
|
-
});
|
|
61
|
-
wrapper.update(); // make sure popup is hidden
|
|
62
|
-
|
|
63
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
64
|
-
});
|
|
65
|
-
it('should hide popup and call onChange after selecting an emoji', function () {
|
|
66
|
-
// click the button
|
|
67
|
-
wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
|
|
68
|
-
|
|
69
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
70
|
-
var emojiPicker = wrapper.find('EmojiPickerInternal').instance(); // calling mock callback
|
|
71
|
-
|
|
72
|
-
act(function () {
|
|
73
|
-
emojiPicker.props.onSelection({
|
|
74
|
-
shortName: ':smiley:'
|
|
75
|
-
});
|
|
76
|
-
}); // make sure the on change callback is called
|
|
77
|
-
|
|
78
|
-
expect(onChangeMock).toBeCalledWith({
|
|
79
|
-
shortName: ':smiley:'
|
|
80
|
-
});
|
|
81
|
-
wrapper.update(); // make sure popup is hidden
|
|
82
|
-
|
|
83
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
8
|
-
import { caption, doc, media, mediaSingle, p } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
9
|
-
import * as analyticsUtils from '../../analytics/utils';
|
|
10
|
-
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from './captions';
|
|
11
|
-
describe('Caption plugin', function () {
|
|
12
|
-
var createEditor = createEditorFactory();
|
|
13
|
-
|
|
14
|
-
var editor = function editor(doc) {
|
|
15
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16
|
-
return createEditor(_objectSpread({
|
|
17
|
-
doc: doc
|
|
18
|
-
}, opts));
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
it('should insert the caption node and select it', function () {
|
|
22
|
-
var _editor = editor(doc('{<node>}', mediaSingle()(media({
|
|
23
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
24
|
-
type: 'file',
|
|
25
|
-
collection: 'MediaServicesSample'
|
|
26
|
-
})()), p('Line two')), {
|
|
27
|
-
editorProps: {
|
|
28
|
-
media: {
|
|
29
|
-
allowMediaSingle: true,
|
|
30
|
-
featureFlags: {
|
|
31
|
-
captions: true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
editorView = _editor.editorView;
|
|
37
|
-
|
|
38
|
-
insertAndSelectCaptionFromMediaSinglePos(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
39
|
-
expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
|
|
40
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
41
|
-
type: 'file',
|
|
42
|
-
collection: 'MediaServicesSample'
|
|
43
|
-
})(), caption('{<>}')), p('Line two')));
|
|
44
|
-
});
|
|
45
|
-
it('should not insert the caption node when it exists already', function () {
|
|
46
|
-
var _editor2 = editor(doc('{<node>}', mediaSingle()(media({
|
|
47
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
48
|
-
type: 'file',
|
|
49
|
-
collection: 'MediaServicesSample'
|
|
50
|
-
})(), caption('test')), p('Line two')), {
|
|
51
|
-
editorProps: {
|
|
52
|
-
media: {
|
|
53
|
-
allowMediaSingle: true,
|
|
54
|
-
featureFlags: {
|
|
55
|
-
captions: true
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
editorView = _editor2.editorView;
|
|
61
|
-
|
|
62
|
-
expect(insertAndSelectCaptionFromMediaSinglePos(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch)).toBeFalsy();
|
|
63
|
-
});
|
|
64
|
-
it('create an added analytic for captions', function () {
|
|
65
|
-
var addAnalyticsSpy = jest.spyOn(analyticsUtils, 'addAnalytics');
|
|
66
|
-
|
|
67
|
-
var _editor3 = editor(doc('{<node>}', mediaSingle()(media({
|
|
68
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
69
|
-
type: 'file',
|
|
70
|
-
collection: 'MediaServicesSample'
|
|
71
|
-
})()), p('Line two')), {
|
|
72
|
-
editorProps: {
|
|
73
|
-
media: {
|
|
74
|
-
allowMediaSingle: true,
|
|
75
|
-
featureFlags: {
|
|
76
|
-
captions: true
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}),
|
|
81
|
-
editorView = _editor3.editorView;
|
|
82
|
-
|
|
83
|
-
insertAndSelectCaptionFromMediaSinglePos(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
84
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
85
|
-
expect(addAnalyticsSpy.mock.calls[0][2]).toEqual({
|
|
86
|
-
action: 'added',
|
|
87
|
-
actionSubject: 'mediaSingle',
|
|
88
|
-
actionSubjectId: 'caption',
|
|
89
|
-
eventType: 'track'
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
it('should move selection to an existing caption node', function () {
|
|
93
|
-
var _editor4 = editor(doc('{<node>}', mediaSingle()(media({
|
|
94
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
95
|
-
type: 'file',
|
|
96
|
-
collection: 'MediaServicesSample'
|
|
97
|
-
})(), caption('hello world')), p('Line two')), {
|
|
98
|
-
editorProps: {
|
|
99
|
-
media: {
|
|
100
|
-
allowMediaSingle: true,
|
|
101
|
-
featureFlags: {
|
|
102
|
-
captions: true
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}),
|
|
107
|
-
editorView = _editor4.editorView;
|
|
108
|
-
|
|
109
|
-
selectCaptionFromMediaSinglePos(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
110
|
-
expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
|
|
111
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
112
|
-
type: 'file',
|
|
113
|
-
collection: 'MediaServicesSample'
|
|
114
|
-
})(), caption('hello world{<>}')), p('Line two')));
|
|
115
|
-
});
|
|
116
|
-
it('should not move selection to a non existing caption node', function () {
|
|
117
|
-
var _editor5 = editor(doc('{<node>}', mediaSingle()(media({
|
|
118
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
119
|
-
type: 'file',
|
|
120
|
-
collection: 'MediaServicesSample'
|
|
121
|
-
})()), p('Line two')), {
|
|
122
|
-
editorProps: {
|
|
123
|
-
media: {
|
|
124
|
-
allowMediaSingle: true,
|
|
125
|
-
featureFlags: {
|
|
126
|
-
captions: true
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}),
|
|
131
|
-
editorView = _editor5.editorView;
|
|
132
|
-
|
|
133
|
-
expect(selectCaptionFromMediaSinglePos(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch)).toBeFalsy();
|
|
134
|
-
});
|
|
135
|
-
});
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import { a, doc, media, mediaSingle } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
4
|
-
import { flushPromises, getDefaultMediaClientConfig } from '@atlaskit/media-test-helpers';
|
|
5
|
-
import { createProsemirrorEditorFactory, Preset } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
|
-
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
7
|
-
import { ProviderFactory } from '@atlaskit/editor-common';
|
|
8
|
-
import hyperlinkPlugin from '../../hyperlink';
|
|
9
|
-
import mediaPlugin from '../';
|
|
10
|
-
import { MediaLinkingActionsTypes } from '../pm-plugins/linking/actions';
|
|
11
|
-
import { checkMediaType } from '../utils/check-media-type';
|
|
12
|
-
import { mediaLinkingPluginKey } from '../pm-plugins/linking';
|
|
13
|
-
import * as linking from './linking';
|
|
14
|
-
import { INPUT_METHOD } from '../../analytics/types';
|
|
15
|
-
import * as analyticUtils from '../../analytics/utils';
|
|
16
|
-
import * as commands from '../../../commands';
|
|
17
|
-
var setUrlToMedia = linking.setUrlToMedia,
|
|
18
|
-
showLinkingToolbarWithMediaTypeCheck = linking.showLinkingToolbarWithMediaTypeCheck,
|
|
19
|
-
unlink = linking.unlink;
|
|
20
|
-
jest.mock('../utils/check-media-type', function () {
|
|
21
|
-
return {
|
|
22
|
-
checkMediaType: jest.fn()
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
describe('image linking', function () {
|
|
26
|
-
var createEditor = createProsemirrorEditorFactory();
|
|
27
|
-
var preset = new Preset();
|
|
28
|
-
var mediaProvider = Promise.resolve({
|
|
29
|
-
viewMediaClientConfig: getDefaultMediaClientConfig()
|
|
30
|
-
});
|
|
31
|
-
var providerFactory = ProviderFactory.create({
|
|
32
|
-
mediaProvider: mediaProvider
|
|
33
|
-
});
|
|
34
|
-
preset.add([mediaPlugin, {
|
|
35
|
-
allowMediaSingle: true,
|
|
36
|
-
allowLinking: true
|
|
37
|
-
}]).add(hyperlinkPlugin);
|
|
38
|
-
|
|
39
|
-
var editor = function editor(doc) {
|
|
40
|
-
return createEditor({
|
|
41
|
-
doc: doc,
|
|
42
|
-
preset: preset,
|
|
43
|
-
providerFactory: providerFactory
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var document = doc('{<node>}', mediaSingle()(media({
|
|
48
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
49
|
-
type: 'file',
|
|
50
|
-
collection: 'MediaServicesSample'
|
|
51
|
-
})()), mediaSingle()(media({
|
|
52
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
53
|
-
type: 'file',
|
|
54
|
-
collection: 'MediaServicesSample'
|
|
55
|
-
})()));
|
|
56
|
-
var mockDispatch = jest.fn();
|
|
57
|
-
afterEach(function () {
|
|
58
|
-
mockDispatch.mockClear();
|
|
59
|
-
});
|
|
60
|
-
describe('analytics', function () {
|
|
61
|
-
var FIRST_CALL = 0;
|
|
62
|
-
var ANALYTIC_PAYLOAD = 2;
|
|
63
|
-
var analyticUtilsSpy = jest.spyOn(analyticUtils, 'addAnalytics');
|
|
64
|
-
beforeEach(function () {
|
|
65
|
-
analyticUtilsSpy.mockReset();
|
|
66
|
-
});
|
|
67
|
-
afterAll(function () {
|
|
68
|
-
jest.resetAllMocks();
|
|
69
|
-
});
|
|
70
|
-
it('should call analytic when creating a link', function () {
|
|
71
|
-
var _editor = editor(document),
|
|
72
|
-
editorView = _editor.editorView;
|
|
73
|
-
|
|
74
|
-
setUrlToMedia('http://google.com', INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
75
|
-
expect(analyticUtilsSpy).toBeCalled();
|
|
76
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
77
|
-
action: 'added',
|
|
78
|
-
actionSubject: 'media',
|
|
79
|
-
actionSubjectId: 'link',
|
|
80
|
-
attributes: expect.objectContaining({
|
|
81
|
-
inputMethod: 'manual'
|
|
82
|
-
}),
|
|
83
|
-
eventType: 'track'
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
describe('existing links', function () {
|
|
87
|
-
var googleUrl = 'http://google.com';
|
|
88
|
-
var documentWithMediaWithLink = doc('{<node>}', mediaSingle()(a({
|
|
89
|
-
href: googleUrl
|
|
90
|
-
})(media({
|
|
91
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
92
|
-
type: 'file',
|
|
93
|
-
collection: 'MediaServicesSample'
|
|
94
|
-
})())));
|
|
95
|
-
it('should add edit analytic when modifying link', function () {
|
|
96
|
-
var _editor2 = editor(documentWithMediaWithLink),
|
|
97
|
-
editorView = _editor2.editorView;
|
|
98
|
-
|
|
99
|
-
setUrlToMedia('http://random-url.com', INPUT_METHOD.MANUAL)(editorView.state, editorView.dispatch, editorView);
|
|
100
|
-
expect(analyticUtilsSpy).toHaveBeenCalledTimes(1);
|
|
101
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
102
|
-
action: 'edited',
|
|
103
|
-
actionSubject: 'media',
|
|
104
|
-
actionSubjectId: 'link',
|
|
105
|
-
eventType: 'track'
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
it('should delete analytic when removing a link', function () {
|
|
109
|
-
var _editor3 = editor(documentWithMediaWithLink),
|
|
110
|
-
editorView = _editor3.editorView;
|
|
111
|
-
|
|
112
|
-
unlink(editorView.state, editorView.dispatch, editorView);
|
|
113
|
-
expect(analyticUtilsSpy).toBeCalledTimes(1);
|
|
114
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
115
|
-
action: 'deleted',
|
|
116
|
-
actionSubject: 'media',
|
|
117
|
-
actionSubjectId: 'link',
|
|
118
|
-
eventType: 'track'
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
it("shouldn't call an analytic if the url was modified to the same url", function () {
|
|
122
|
-
var _editor4 = editor(documentWithMediaWithLink),
|
|
123
|
-
editorView = _editor4.editorView;
|
|
124
|
-
|
|
125
|
-
setUrlToMedia(googleUrl, INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
126
|
-
expect(analyticUtilsSpy).not.toBeCalled();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe('errors', function () {
|
|
130
|
-
beforeAll(function () {
|
|
131
|
-
jest.spyOn(commands, 'createToggleBlockMarkOnRange').mockImplementation(function () {
|
|
132
|
-
throw new Error('This error should be caught');
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
it("should call analytic if there's an error creating a link", function () {
|
|
136
|
-
var _editor5 = editor(document),
|
|
137
|
-
editorView = _editor5.editorView;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
setUrlToMedia('http://google.com', INPUT_METHOD.MANUAL)(editorView.state, mockDispatch, editorView);
|
|
141
|
-
} catch (e) {// noop
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
expect(analyticUtilsSpy.mock.calls[FIRST_CALL][ANALYTIC_PAYLOAD]).toEqual({
|
|
145
|
-
action: 'errored',
|
|
146
|
-
actionSubject: 'media',
|
|
147
|
-
actionSubjectId: 'link',
|
|
148
|
-
attributes: {
|
|
149
|
-
action: 'added'
|
|
150
|
-
},
|
|
151
|
-
eventType: 'track'
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
describe('show linking toolbar', function () {
|
|
157
|
-
describe('selected media is an image', function () {
|
|
158
|
-
beforeAll(function () {
|
|
159
|
-
checkMediaType.mockReturnValue(Promise.resolve('image'));
|
|
160
|
-
});
|
|
161
|
-
it('call dispatch with correct param with a media is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
162
|
-
var _editor6, editorView, result, expectTransaction;
|
|
163
|
-
|
|
164
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
165
|
-
while (1) {
|
|
166
|
-
switch (_context.prev = _context.next) {
|
|
167
|
-
case 0:
|
|
168
|
-
_editor6 = editor(document), editorView = _editor6.editorView;
|
|
169
|
-
_context.next = 3;
|
|
170
|
-
return flushPromises();
|
|
171
|
-
|
|
172
|
-
case 3:
|
|
173
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
174
|
-
expectTransaction = editorView.state.tr.setMeta(mediaLinkingPluginKey, {
|
|
175
|
-
type: MediaLinkingActionsTypes.showToolbar
|
|
176
|
-
});
|
|
177
|
-
_context.next = 7;
|
|
178
|
-
return flushPromises();
|
|
179
|
-
|
|
180
|
-
case 7:
|
|
181
|
-
expect(result).toEqual(true);
|
|
182
|
-
expect(mockDispatch).toHaveBeenCalledWith(expectTransaction);
|
|
183
|
-
|
|
184
|
-
case 9:
|
|
185
|
-
case "end":
|
|
186
|
-
return _context.stop();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}, _callee);
|
|
190
|
-
})));
|
|
191
|
-
it('does not call dispatch when selection is not a media single node', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
192
|
-
var _editor7, editorView, result;
|
|
193
|
-
|
|
194
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
195
|
-
while (1) {
|
|
196
|
-
switch (_context2.prev = _context2.next) {
|
|
197
|
-
case 0:
|
|
198
|
-
_editor7 = editor(document), editorView = _editor7.editorView;
|
|
199
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
200
|
-
_context2.next = 4;
|
|
201
|
-
return flushPromises();
|
|
202
|
-
|
|
203
|
-
case 4:
|
|
204
|
-
expect(result).toEqual(false);
|
|
205
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
206
|
-
|
|
207
|
-
case 6:
|
|
208
|
-
case "end":
|
|
209
|
-
return _context2.stop();
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}, _callee2);
|
|
213
|
-
})));
|
|
214
|
-
it('does not call dispatch when selection has changed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
215
|
-
var _editor8, editorView, result;
|
|
216
|
-
|
|
217
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
218
|
-
while (1) {
|
|
219
|
-
switch (_context3.prev = _context3.next) {
|
|
220
|
-
case 0:
|
|
221
|
-
_editor8 = editor(document), editorView = _editor8.editorView;
|
|
222
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
223
|
-
sendKeyToPm(editorView, 'ArrowDown');
|
|
224
|
-
_context3.next = 5;
|
|
225
|
-
return flushPromises();
|
|
226
|
-
|
|
227
|
-
case 5:
|
|
228
|
-
expect(result).toEqual(false);
|
|
229
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
230
|
-
|
|
231
|
-
case 7:
|
|
232
|
-
case "end":
|
|
233
|
-
return _context3.stop();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}, _callee3);
|
|
237
|
-
})));
|
|
238
|
-
});
|
|
239
|
-
describe('selected media is a video', function () {
|
|
240
|
-
beforeAll(function () {
|
|
241
|
-
checkMediaType.mockReturnValue(Promise.resolve('video'));
|
|
242
|
-
});
|
|
243
|
-
it('does not call dispatch', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
244
|
-
var _editor9, editorView, result;
|
|
245
|
-
|
|
246
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
247
|
-
while (1) {
|
|
248
|
-
switch (_context4.prev = _context4.next) {
|
|
249
|
-
case 0:
|
|
250
|
-
_editor9 = editor(document), editorView = _editor9.editorView;
|
|
251
|
-
result = showLinkingToolbarWithMediaTypeCheck(editorView.state, mockDispatch, editorView);
|
|
252
|
-
_context4.next = 4;
|
|
253
|
-
return flushPromises();
|
|
254
|
-
|
|
255
|
-
case 4:
|
|
256
|
-
expect(result).toEqual(false);
|
|
257
|
-
expect(mockDispatch).not.toHaveBeenCalled();
|
|
258
|
-
|
|
259
|
-
case 6:
|
|
260
|
-
case "end":
|
|
261
|
-
return _context4.stop();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}, _callee4);
|
|
265
|
-
})));
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { IntlProvider } from 'react-intl';
|
|
4
|
-
import { N200 } from '@atlaskit/theme/colors';
|
|
5
|
-
import { messages } from './messages';
|
|
6
|
-
import CaptionPlaceholder from './index';
|
|
7
|
-
|
|
8
|
-
var renderWithIntl = function renderWithIntl(component) {
|
|
9
|
-
return render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
10
|
-
locale: "en"
|
|
11
|
-
}, component));
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var onClick = function onClick() {};
|
|
15
|
-
|
|
16
|
-
describe('CaptionComponent', function () {
|
|
17
|
-
it('should show a placeholder by default', function () {
|
|
18
|
-
var _renderWithIntl = renderWithIntl( /*#__PURE__*/React.createElement(CaptionPlaceholder, {
|
|
19
|
-
onClick: onClick
|
|
20
|
-
})),
|
|
21
|
-
getByText = _renderWithIntl.getByText;
|
|
22
|
-
|
|
23
|
-
expect(getByText(messages.placeholder.defaultMessage)).not.toBeNull();
|
|
24
|
-
});
|
|
25
|
-
it('should have the placeholder colour as N200', function () {
|
|
26
|
-
var _renderWithIntl2 = renderWithIntl( /*#__PURE__*/React.createElement(CaptionPlaceholder, {
|
|
27
|
-
onClick: onClick
|
|
28
|
-
})),
|
|
29
|
-
container = _renderWithIntl2.container;
|
|
30
|
-
|
|
31
|
-
expect(container.firstChild).toHaveStyle("color: ".concat(N200));
|
|
32
|
-
});
|
|
33
|
-
it('placeholder should be centered', function () {
|
|
34
|
-
var _renderWithIntl3 = renderWithIntl( /*#__PURE__*/React.createElement(CaptionPlaceholder, {
|
|
35
|
-
onClick: onClick
|
|
36
|
-
})),
|
|
37
|
-
container = _renderWithIntl3.container;
|
|
38
|
-
|
|
39
|
-
expect(container.firstChild).toHaveStyle("text-align: center");
|
|
40
|
-
});
|
|
41
|
-
});
|