@atlaskit/editor-core 150.0.1 → 151.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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/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 +9 -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/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/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 +9 -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/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/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 +9 -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/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 +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/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/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/index.d.ts +1 -0
- 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 +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 +22 -19
- 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,141 +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 _createProsemirrorEditor = require("@atlaskit/editor-test-helpers/create-prosemirror-editor");
|
|
8
|
-
|
|
9
|
-
var _media = _interopRequireDefault(require("../../media"));
|
|
10
|
-
|
|
11
|
-
var _ = _interopRequireDefault(require("../"));
|
|
12
|
-
|
|
13
|
-
var _docBuilder = require("@atlaskit/editor-test-helpers/doc-builder");
|
|
14
|
-
|
|
15
|
-
var _pluginKey = require("./plugin-key");
|
|
16
|
-
|
|
17
|
-
var _selection = require("../../../utils/selection");
|
|
18
|
-
|
|
19
|
-
var analyticsUtils = _interopRequireWildcard(require("../../analytics/utils"));
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
describe('Caption plugin', function () {
|
|
26
|
-
var createEditor = (0, _createProsemirrorEditor.createProsemirrorEditorFactory)();
|
|
27
|
-
|
|
28
|
-
var editor = function editor(doc) {
|
|
29
|
-
return createEditor({
|
|
30
|
-
doc: doc,
|
|
31
|
-
pluginKey: _pluginKey.pluginKey,
|
|
32
|
-
preset: new _createProsemirrorEditor.Preset().add([_media.default, {
|
|
33
|
-
allowMediaSingle: true,
|
|
34
|
-
featureFlags: {
|
|
35
|
-
captions: true
|
|
36
|
-
}
|
|
37
|
-
}]).add(_.default)
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
it('should not remove caption when there is content', function () {
|
|
42
|
-
var _editor = editor((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
43
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
44
|
-
type: 'file',
|
|
45
|
-
collection: 'MediaServicesSample'
|
|
46
|
-
})(), (0, _docBuilder.caption)('Test{<>}')), (0, _docBuilder.p)('Line {movePos}two'))),
|
|
47
|
-
editorView = _editor.editorView,
|
|
48
|
-
movePos = _editor.refs.movePos;
|
|
49
|
-
|
|
50
|
-
(0, _selection.setTextSelection)(editorView, movePos);
|
|
51
|
-
expect(editorView.state.doc).toEqualDocument((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
52
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
53
|
-
type: 'file',
|
|
54
|
-
collection: 'MediaServicesSample'
|
|
55
|
-
})(), (0, _docBuilder.caption)('Test')), (0, _docBuilder.p)('Line two')));
|
|
56
|
-
});
|
|
57
|
-
it('should remove caption when there is no content', function () {
|
|
58
|
-
var _editor2 = editor((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
59
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
60
|
-
type: 'file',
|
|
61
|
-
collection: 'MediaServicesSample'
|
|
62
|
-
})(), (0, _docBuilder.caption)('{<>}')), (0, _docBuilder.p)('Line {movePos}two'))),
|
|
63
|
-
editorView = _editor2.editorView,
|
|
64
|
-
movePos = _editor2.refs.movePos;
|
|
65
|
-
|
|
66
|
-
(0, _selection.setTextSelection)(editorView, movePos);
|
|
67
|
-
expect(editorView.state.doc).toEqualDocument((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
68
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
69
|
-
type: 'file',
|
|
70
|
-
collection: 'MediaServicesSample'
|
|
71
|
-
})()), (0, _docBuilder.p)('Line two')));
|
|
72
|
-
});
|
|
73
|
-
it('should remove caption when clicking onto another caption', function () {
|
|
74
|
-
var _editor3 = editor((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
75
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
76
|
-
type: 'file',
|
|
77
|
-
collection: 'MediaServicesSample'
|
|
78
|
-
})(), (0, _docBuilder.caption)('{<>}')), (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
79
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
80
|
-
type: 'file',
|
|
81
|
-
collection: 'MediaServicesSample'
|
|
82
|
-
})(), (0, _docBuilder.caption)('second {movePos}caption')))),
|
|
83
|
-
editorView = _editor3.editorView,
|
|
84
|
-
movePos = _editor3.refs.movePos;
|
|
85
|
-
|
|
86
|
-
(0, _selection.setTextSelection)(editorView, movePos);
|
|
87
|
-
expect(editorView.state.doc).toEqualDocument((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
88
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
89
|
-
type: 'file',
|
|
90
|
-
collection: 'MediaServicesSample'
|
|
91
|
-
})()), (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
92
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
93
|
-
type: 'file',
|
|
94
|
-
collection: 'MediaServicesSample'
|
|
95
|
-
})(), (0, _docBuilder.caption)('second caption'))));
|
|
96
|
-
});
|
|
97
|
-
describe('analytics', function () {
|
|
98
|
-
var addAnalyticsSpy = jest.spyOn(analyticsUtils, 'addAnalytics');
|
|
99
|
-
var FIRST_CALL = 0;
|
|
100
|
-
var PAYLOAD_ARGUMENT = 2;
|
|
101
|
-
beforeEach(function () {
|
|
102
|
-
addAnalyticsSpy.mockReset();
|
|
103
|
-
});
|
|
104
|
-
it('should fire deleted analytic when removing caption', function () {
|
|
105
|
-
var _editor4 = editor((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
106
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
107
|
-
type: 'file',
|
|
108
|
-
collection: 'MediaServicesSample'
|
|
109
|
-
})(), (0, _docBuilder.caption)('{<>}')), (0, _docBuilder.p)('Line {movePos}two'))),
|
|
110
|
-
editorView = _editor4.editorView,
|
|
111
|
-
movePos = _editor4.refs.movePos;
|
|
112
|
-
|
|
113
|
-
(0, _selection.setTextSelection)(editorView, movePos);
|
|
114
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
115
|
-
expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
|
|
116
|
-
action: 'deleted',
|
|
117
|
-
actionSubject: 'mediaSingle',
|
|
118
|
-
actionSubjectId: 'caption',
|
|
119
|
-
eventType: 'track'
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
it('should fire edited analytic when moving away from a non empty caption', function () {
|
|
123
|
-
var _editor5 = editor((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
124
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
125
|
-
type: 'file',
|
|
126
|
-
collection: 'MediaServicesSample'
|
|
127
|
-
})(), (0, _docBuilder.caption)('Test{<>}')), (0, _docBuilder.p)('Line {movePos}two'))),
|
|
128
|
-
editorView = _editor5.editorView,
|
|
129
|
-
movePos = _editor5.refs.movePos;
|
|
130
|
-
|
|
131
|
-
(0, _selection.setTextSelection)(editorView, movePos);
|
|
132
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
133
|
-
expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
|
|
134
|
-
action: 'edited',
|
|
135
|
-
actionSubject: 'mediaSingle',
|
|
136
|
-
actionSubjectId: 'caption',
|
|
137
|
-
eventType: 'track'
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _languageList = require("./language-list");
|
|
4
|
-
|
|
5
|
-
var mockSupportedLanguages = [{
|
|
6
|
-
name: 'JSON',
|
|
7
|
-
alias: ['json'],
|
|
8
|
-
value: 'json'
|
|
9
|
-
}, {
|
|
10
|
-
name: 'JavaScript',
|
|
11
|
-
alias: ['javascript', 'js'],
|
|
12
|
-
value: 'javascript'
|
|
13
|
-
}, {
|
|
14
|
-
name: 'Python',
|
|
15
|
-
alias: ['python', 'py'],
|
|
16
|
-
value: 'python'
|
|
17
|
-
}];
|
|
18
|
-
describe('languageList utils', function () {
|
|
19
|
-
it('should find matched language', function () {
|
|
20
|
-
expect((0, _languageList.findMatchedLanguage)(mockSupportedLanguages, 'JavaScript')).toEqual({
|
|
21
|
-
name: 'JavaScript',
|
|
22
|
-
alias: ['javascript', 'js'],
|
|
23
|
-
value: 'javascript'
|
|
24
|
-
});
|
|
25
|
-
expect((0, _languageList.findMatchedLanguage)(mockSupportedLanguages, 'Python')).toEqual({
|
|
26
|
-
name: 'Python',
|
|
27
|
-
alias: ['python', 'py'],
|
|
28
|
-
value: 'python'
|
|
29
|
-
});
|
|
30
|
-
expect((0, _languageList.findMatchedLanguage)(mockSupportedLanguages, 'GiBBeRish')).toBeUndefined();
|
|
31
|
-
});
|
|
32
|
-
it('should filter supported languages', function () {
|
|
33
|
-
var mockSupportedLanguageStrings = mockSupportedLanguages.map(function (language) {
|
|
34
|
-
return language.name.toLowerCase();
|
|
35
|
-
});
|
|
36
|
-
expect((0, _languageList.filterSupportedLanguages)([])).toEqual(_languageList.DEFAULT_LANGUAGES);
|
|
37
|
-
expect((0, _languageList.filterSupportedLanguages)(mockSupportedLanguageStrings)).toEqual([{
|
|
38
|
-
name: 'Python',
|
|
39
|
-
alias: ['python', 'py'],
|
|
40
|
-
value: 'python'
|
|
41
|
-
}, {
|
|
42
|
-
name: 'JavaScript',
|
|
43
|
-
alias: ['javascript', 'js'],
|
|
44
|
-
value: 'javascript'
|
|
45
|
-
}, {
|
|
46
|
-
name: 'JSON',
|
|
47
|
-
alias: ['json'],
|
|
48
|
-
value: 'json'
|
|
49
|
-
} // '(None)' is not an actual language and should not be 'supported'
|
|
50
|
-
]);
|
|
51
|
-
});
|
|
52
|
-
it('should get language identifier', function () {
|
|
53
|
-
expect((0, _languageList.getLanguageIdentifier)({
|
|
54
|
-
name: 'MyLanguage',
|
|
55
|
-
alias: ['myalias'],
|
|
56
|
-
value: 'myalias'
|
|
57
|
-
})).toEqual('myalias');
|
|
58
|
-
});
|
|
59
|
-
it('should create language list sorted as case insensitive', function () {
|
|
60
|
-
expect((0, _languageList.createLanguageList)(mockSupportedLanguages)).toEqual([{
|
|
61
|
-
name: 'JavaScript',
|
|
62
|
-
alias: ['javascript', 'js'],
|
|
63
|
-
value: 'javascript'
|
|
64
|
-
}, {
|
|
65
|
-
name: 'JSON',
|
|
66
|
-
alias: ['json'],
|
|
67
|
-
value: 'json'
|
|
68
|
-
}, {
|
|
69
|
-
name: 'Python',
|
|
70
|
-
alias: ['python', 'py'],
|
|
71
|
-
value: 'python'
|
|
72
|
-
}]);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
6
|
-
|
|
7
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
|
-
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
var _react2 = require("@testing-library/react");
|
|
12
|
-
|
|
13
|
-
var _reactIntl = require("react-intl");
|
|
14
|
-
|
|
15
|
-
var _SaveIndicator = require("./SaveIndicator");
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
20
|
-
|
|
21
|
-
jest.useFakeTimers();
|
|
22
|
-
|
|
23
|
-
function setup() {
|
|
24
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
-
|
|
26
|
-
var onSaveStarted = function onSaveStarted() {};
|
|
27
|
-
|
|
28
|
-
var result = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
|
|
29
|
-
locale: "en"
|
|
30
|
-
}, /*#__PURE__*/_react.default.createElement(_SaveIndicator.SaveIndicator, (0, _extends2.default)({
|
|
31
|
-
duration: 2000
|
|
32
|
-
}, props), function (_ref) {
|
|
33
|
-
var _onSaveStarted = _ref.onSaveStarted;
|
|
34
|
-
onSaveStarted = _onSaveStarted;
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
-
"data-testid": "my-component"
|
|
37
|
-
});
|
|
38
|
-
})));
|
|
39
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
40
|
-
onSaveStarted: onSaveStarted
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
describe('Extension Context Panel - Save Indicator', function () {
|
|
45
|
-
it('should call the render function ', function () {
|
|
46
|
-
var renderFunction = jest.fn().mockImplementation(function () {
|
|
47
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
48
|
-
"data-testid": "my-component"
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
var _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
|
|
53
|
-
locale: "en"
|
|
54
|
-
}, /*#__PURE__*/_react.default.createElement(_SaveIndicator.SaveIndicator, {
|
|
55
|
-
duration: 1000
|
|
56
|
-
}, renderFunction))),
|
|
57
|
-
queryByTestId = _render.queryByTestId;
|
|
58
|
-
|
|
59
|
-
expect(queryByTestId('my-component')).not.toBeNull();
|
|
60
|
-
});
|
|
61
|
-
it('should show the save indicator when is saving ', function () {
|
|
62
|
-
var _setup = setup(),
|
|
63
|
-
onSaveStarted = _setup.onSaveStarted,
|
|
64
|
-
queryByTestId = _setup.queryByTestId;
|
|
65
|
-
|
|
66
|
-
(0, _react2.act)(function () {
|
|
67
|
-
onSaveStarted();
|
|
68
|
-
});
|
|
69
|
-
expect(queryByTestId('save-indicator-content')).not.toBeNull();
|
|
70
|
-
});
|
|
71
|
-
it('should hide once the duration is over ', function () {
|
|
72
|
-
jest.clearAllTimers();
|
|
73
|
-
var duration = 2000;
|
|
74
|
-
|
|
75
|
-
var _setup2 = setup({
|
|
76
|
-
duration: duration
|
|
77
|
-
}),
|
|
78
|
-
onSaveStarted = _setup2.onSaveStarted,
|
|
79
|
-
queryByTestId = _setup2.queryByTestId;
|
|
80
|
-
|
|
81
|
-
(0, _react2.act)(function () {
|
|
82
|
-
onSaveStarted();
|
|
83
|
-
});
|
|
84
|
-
(0, _react2.act)(function () {
|
|
85
|
-
jest.advanceTimersByTime(duration);
|
|
86
|
-
});
|
|
87
|
-
expect(queryByTestId('save-indicator-content')).toBeNull();
|
|
88
|
-
});
|
|
89
|
-
it('should not show the save indicator after saving when visible is false ', function () {
|
|
90
|
-
var _setup3 = setup({
|
|
91
|
-
visible: false
|
|
92
|
-
}),
|
|
93
|
-
onSaveStarted = _setup3.onSaveStarted,
|
|
94
|
-
queryByTestId = _setup3.queryByTestId;
|
|
95
|
-
|
|
96
|
-
(0, _react2.act)(function () {
|
|
97
|
-
onSaveStarted();
|
|
98
|
-
});
|
|
99
|
-
expect(queryByTestId('save-indicator-content')).toBeNull();
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _enzyme = require("@atlaskit/editor-test-helpers/enzyme");
|
|
8
|
-
|
|
9
|
-
var _createProsemirrorEditor = require("@atlaskit/editor-test-helpers/create-prosemirror-editor");
|
|
10
|
-
|
|
11
|
-
var _docBuilder = require("@atlaskit/editor-test-helpers/doc-builder");
|
|
12
|
-
|
|
13
|
-
var _EmojiPickerButton = require("./EmojiPickerButton");
|
|
14
|
-
|
|
15
|
-
var _panel = _interopRequireDefault(require("../../panel"));
|
|
16
|
-
|
|
17
|
-
var _editorCommon = require("@atlaskit/editor-common");
|
|
18
|
-
|
|
19
|
-
var _getTestEmojiResource = require("@atlaskit/util-data-test/get-test-emoji-resource");
|
|
20
|
-
|
|
21
|
-
var _testUtils = require("react-dom/test-utils");
|
|
22
|
-
|
|
23
|
-
describe('emoji-picker-button', function () {
|
|
24
|
-
var createEditor = (0, _createProsemirrorEditor.createProsemirrorEditorFactory)();
|
|
25
|
-
var wrapper;
|
|
26
|
-
var onChangeMock;
|
|
27
|
-
var providerFactory = new _editorCommon.ProviderFactory();
|
|
28
|
-
var panelPreset = new _createProsemirrorEditor.Preset().add([_panel.default, {
|
|
29
|
-
UNSAFE_allowCustomPanel: true
|
|
30
|
-
}]);
|
|
31
|
-
beforeEach(function () {
|
|
32
|
-
var _createEditor = createEditor({
|
|
33
|
-
doc: (0, _docBuilder.doc)((0, _docBuilder.panel)({
|
|
34
|
-
panelType: 'info'
|
|
35
|
-
})((0, _docBuilder.p)('{<>}'))),
|
|
36
|
-
preset: panelPreset,
|
|
37
|
-
providerFactory: providerFactory
|
|
38
|
-
}),
|
|
39
|
-
editorView = _createEditor.editorView;
|
|
40
|
-
|
|
41
|
-
providerFactory.setProvider('emojiProvider', Promise.resolve((0, _getTestEmojiResource.getTestEmojiResource)()));
|
|
42
|
-
onChangeMock = jest.fn();
|
|
43
|
-
wrapper = (0, _enzyme.mountWithIntl)( /*#__PURE__*/_react.default.createElement(_EmojiPickerButton.EmojiPickerButton, {
|
|
44
|
-
view: editorView,
|
|
45
|
-
providerFactory: providerFactory,
|
|
46
|
-
onChange: onChangeMock
|
|
47
|
-
}));
|
|
48
|
-
});
|
|
49
|
-
afterEach(function () {
|
|
50
|
-
providerFactory.removeProvider('emojiProvider');
|
|
51
|
-
wrapper && wrapper.unmount();
|
|
52
|
-
});
|
|
53
|
-
it('should render a button', function () {
|
|
54
|
-
expect(wrapper.find('button')).toHaveLength(1); // ensure no popup is rendered
|
|
55
|
-
|
|
56
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
57
|
-
});
|
|
58
|
-
it('should show a EmojiPicker popup after clicking button', function () {
|
|
59
|
-
// popup still not shown before the click
|
|
60
|
-
wrapper.find('button').simulate('click'); // show the popup
|
|
61
|
-
|
|
62
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
63
|
-
});
|
|
64
|
-
it('should close EmojiPicker popup after clicking outside', function () {
|
|
65
|
-
// clicking on the button to open the popup
|
|
66
|
-
wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
|
|
67
|
-
|
|
68
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
69
|
-
var emojiPicker = wrapper.find('EmojiPickerInternal').instance(); // calling click outside
|
|
70
|
-
|
|
71
|
-
(0, _testUtils.act)(function () {
|
|
72
|
-
emojiPicker.props.handleClickOutside();
|
|
73
|
-
});
|
|
74
|
-
wrapper.update(); // make sure popup is hidden
|
|
75
|
-
|
|
76
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
77
|
-
});
|
|
78
|
-
it('should hide popup and call onChange after selecting an emoji', function () {
|
|
79
|
-
// click the button
|
|
80
|
-
wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
|
|
81
|
-
|
|
82
|
-
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
83
|
-
var emojiPicker = wrapper.find('EmojiPickerInternal').instance(); // calling mock callback
|
|
84
|
-
|
|
85
|
-
(0, _testUtils.act)(function () {
|
|
86
|
-
emojiPicker.props.onSelection({
|
|
87
|
-
shortName: ':smiley:'
|
|
88
|
-
});
|
|
89
|
-
}); // make sure the on change callback is called
|
|
90
|
-
|
|
91
|
-
expect(onChangeMock).toBeCalledWith({
|
|
92
|
-
shortName: ':smiley:'
|
|
93
|
-
});
|
|
94
|
-
wrapper.update(); // make sure popup is hidden
|
|
95
|
-
|
|
96
|
-
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1,149 +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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
-
|
|
9
|
-
var _createEditor = require("@atlaskit/editor-test-helpers/create-editor");
|
|
10
|
-
|
|
11
|
-
var _docBuilder = require("@atlaskit/editor-test-helpers/doc-builder");
|
|
12
|
-
|
|
13
|
-
var analyticsUtils = _interopRequireWildcard(require("../../analytics/utils"));
|
|
14
|
-
|
|
15
|
-
var _captions = require("./captions");
|
|
16
|
-
|
|
17
|
-
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); }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
23
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
24
|
-
|
|
25
|
-
describe('Caption plugin', function () {
|
|
26
|
-
var createEditor = (0, _createEditor.createEditorFactory)();
|
|
27
|
-
|
|
28
|
-
var editor = function editor(doc) {
|
|
29
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
30
|
-
return createEditor(_objectSpread({
|
|
31
|
-
doc: doc
|
|
32
|
-
}, opts));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
it('should insert the caption node and select it', function () {
|
|
36
|
-
var _editor = editor((0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
37
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
38
|
-
type: 'file',
|
|
39
|
-
collection: 'MediaServicesSample'
|
|
40
|
-
})()), (0, _docBuilder.p)('Line two')), {
|
|
41
|
-
editorProps: {
|
|
42
|
-
media: {
|
|
43
|
-
allowMediaSingle: true,
|
|
44
|
-
featureFlags: {
|
|
45
|
-
captions: true
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}),
|
|
50
|
-
editorView = _editor.editorView;
|
|
51
|
-
|
|
52
|
-
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
53
|
-
expect(editorView.state).toEqualDocumentAndSelection((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
54
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
55
|
-
type: 'file',
|
|
56
|
-
collection: 'MediaServicesSample'
|
|
57
|
-
})(), (0, _docBuilder.caption)('{<>}')), (0, _docBuilder.p)('Line two')));
|
|
58
|
-
});
|
|
59
|
-
it('should not insert the caption node when it exists already', function () {
|
|
60
|
-
var _editor2 = editor((0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
61
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
62
|
-
type: 'file',
|
|
63
|
-
collection: 'MediaServicesSample'
|
|
64
|
-
})(), (0, _docBuilder.caption)('test')), (0, _docBuilder.p)('Line two')), {
|
|
65
|
-
editorProps: {
|
|
66
|
-
media: {
|
|
67
|
-
allowMediaSingle: true,
|
|
68
|
-
featureFlags: {
|
|
69
|
-
captions: true
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}),
|
|
74
|
-
editorView = _editor2.editorView;
|
|
75
|
-
|
|
76
|
-
expect((0, _captions.insertAndSelectCaptionFromMediaSinglePos)(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch)).toBeFalsy();
|
|
77
|
-
});
|
|
78
|
-
it('create an added analytic for captions', function () {
|
|
79
|
-
var addAnalyticsSpy = jest.spyOn(analyticsUtils, 'addAnalytics');
|
|
80
|
-
|
|
81
|
-
var _editor3 = editor((0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
82
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
83
|
-
type: 'file',
|
|
84
|
-
collection: 'MediaServicesSample'
|
|
85
|
-
})()), (0, _docBuilder.p)('Line two')), {
|
|
86
|
-
editorProps: {
|
|
87
|
-
media: {
|
|
88
|
-
allowMediaSingle: true,
|
|
89
|
-
featureFlags: {
|
|
90
|
-
captions: true
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}),
|
|
95
|
-
editorView = _editor3.editorView;
|
|
96
|
-
|
|
97
|
-
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
98
|
-
expect(addAnalyticsSpy).toBeCalled();
|
|
99
|
-
expect(addAnalyticsSpy.mock.calls[0][2]).toEqual({
|
|
100
|
-
action: 'added',
|
|
101
|
-
actionSubject: 'mediaSingle',
|
|
102
|
-
actionSubjectId: 'caption',
|
|
103
|
-
eventType: 'track'
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it('should move selection to an existing caption node', function () {
|
|
107
|
-
var _editor4 = editor((0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
108
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
109
|
-
type: 'file',
|
|
110
|
-
collection: 'MediaServicesSample'
|
|
111
|
-
})(), (0, _docBuilder.caption)('hello world')), (0, _docBuilder.p)('Line two')), {
|
|
112
|
-
editorProps: {
|
|
113
|
-
media: {
|
|
114
|
-
allowMediaSingle: true,
|
|
115
|
-
featureFlags: {
|
|
116
|
-
captions: true
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
121
|
-
editorView = _editor4.editorView;
|
|
122
|
-
|
|
123
|
-
(0, _captions.selectCaptionFromMediaSinglePos)(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch);
|
|
124
|
-
expect(editorView.state).toEqualDocumentAndSelection((0, _docBuilder.doc)((0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
125
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
126
|
-
type: 'file',
|
|
127
|
-
collection: 'MediaServicesSample'
|
|
128
|
-
})(), (0, _docBuilder.caption)('hello world{<>}')), (0, _docBuilder.p)('Line two')));
|
|
129
|
-
});
|
|
130
|
-
it('should not move selection to a non existing caption node', function () {
|
|
131
|
-
var _editor5 = editor((0, _docBuilder.doc)('{<node>}', (0, _docBuilder.mediaSingle)()((0, _docBuilder.media)({
|
|
132
|
-
id: 'a559980d-cd47-43e2-8377-27359fcb905f',
|
|
133
|
-
type: 'file',
|
|
134
|
-
collection: 'MediaServicesSample'
|
|
135
|
-
})()), (0, _docBuilder.p)('Line two')), {
|
|
136
|
-
editorProps: {
|
|
137
|
-
media: {
|
|
138
|
-
allowMediaSingle: true,
|
|
139
|
-
featureFlags: {
|
|
140
|
-
captions: true
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}),
|
|
145
|
-
editorView = _editor5.editorView;
|
|
146
|
-
|
|
147
|
-
expect((0, _captions.selectCaptionFromMediaSinglePos)(0, editorView.state.doc.child(0))(editorView.state, editorView.dispatch)).toBeFalsy();
|
|
148
|
-
});
|
|
149
|
-
});
|