@atlaskit/editor-core 182.0.3 → 182.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/.eslintrc.js +2 -0
- package/CHANGELOG.md +47 -0
- package/README.md +20 -0
- package/architecture/0001-record-architecture-decisions.md +25 -0
- package/architecture/0002-deep-equality-check-for-getsharedstate.md +67 -0
- package/architecture/0003-explicit-plugin-dependencies.md +291 -0
- package/dist/cjs/actions/index.js +17 -6
- package/dist/cjs/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/cjs/create-editor/ErrorBoundary.js +1 -16
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +3 -3
- package/dist/cjs/editor-next/editor-internal.js +2 -1
- package/dist/cjs/editor-next/index.js +5 -1
- package/dist/cjs/editor.js +9 -5
- package/dist/cjs/keymaps/index.js +12 -0
- package/dist/cjs/labs/next/internal/hooks/use-editor/index.js +5 -7
- package/dist/cjs/labs/next/presets/default.js +1 -2
- package/dist/cjs/plugins/card/index.js +16 -5
- package/dist/cjs/plugins/card/pm-plugins/actions.js +10 -1
- package/dist/cjs/plugins/card/pm-plugins/analytics/create-analytics-queue.js +48 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/events-from-tr.js +337 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/index.js +19 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/types.js +5 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/utils.js +139 -0
- package/dist/cjs/plugins/card/pm-plugins/doc.js +99 -22
- package/dist/cjs/plugins/card/pm-plugins/main.js +16 -10
- package/dist/cjs/plugins/card/pm-plugins/reducers.js +7 -0
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/cjs/plugins/card/toolbar.js +18 -8
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +12 -8
- package/dist/cjs/plugins/card/ui/EditorSmartCardEventsNext.js +202 -0
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +12 -4
- package/dist/cjs/plugins/card/utils.js +4 -2
- package/dist/cjs/plugins/extension/context-panel.js +3 -2
- package/dist/cjs/plugins/extension/index.js +4 -1
- package/dist/cjs/plugins/help-dialog/ui/index.js +29 -8
- package/dist/cjs/plugins/hyperlink/Toolbar.js +12 -2
- package/dist/cjs/plugins/hyperlink/commands.js +9 -5
- package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/insert-block/index.js +5 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +25 -23
- package/dist/cjs/plugins/media/index.js +9 -5
- package/dist/cjs/plugins/media/pm-plugins/main.js +5 -4
- package/dist/cjs/plugins/media/utils/media-single.js +1 -4
- package/dist/cjs/plugins/panel/pm-plugins/keymaps.js +2 -1
- package/dist/cjs/plugins/paste/handlers.js +5 -5
- package/dist/cjs/plugins/paste/index.js +4 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +6 -4
- package/dist/cjs/plugins/rule/commands.js +2 -2
- package/dist/cjs/plugins/rule/index.js +5 -4
- package/dist/cjs/plugins/rule/pm-plugins/input-rule.js +6 -8
- package/dist/cjs/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/text-color/index.js +5 -2
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +3 -4
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/cjs/ui/ColorPalette/index.js +6 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +15 -10
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +248 -17
- package/dist/cjs/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/cjs/ui/ConfigPanel/utils.js +2 -12
- package/dist/cjs/ui/ContentStyles/index.js +2 -5
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +16 -8
- package/dist/cjs/utils/document.js +5 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +10 -4
- package/dist/es2019/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/es2019/create-editor/ErrorBoundary.js +1 -13
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +2 -2
- package/dist/es2019/editor-next/editor-internal.js +2 -1
- package/dist/es2019/editor-next/index.js +5 -1
- package/dist/es2019/editor.js +5 -2
- package/dist/es2019/keymaps/index.js +1 -1
- package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +4 -6
- package/dist/es2019/labs/next/presets/default.js +1 -2
- package/dist/es2019/plugins/card/index.js +15 -5
- package/dist/es2019/plugins/card/pm-plugins/actions.js +4 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/create-analytics-queue.js +38 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/events-from-tr.js +316 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/index.js +2 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/types.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/utils.js +124 -0
- package/dist/es2019/plugins/card/pm-plugins/doc.js +94 -20
- package/dist/es2019/plugins/card/pm-plugins/main.js +17 -8
- package/dist/es2019/plugins/card/pm-plugins/reducers.js +8 -0
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/es2019/plugins/card/toolbar.js +16 -8
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +13 -9
- package/dist/es2019/plugins/card/ui/EditorSmartCardEventsNext.js +180 -0
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +11 -2
- package/dist/es2019/plugins/card/utils.js +6 -2
- package/dist/es2019/plugins/extension/context-panel.js +3 -2
- package/dist/es2019/plugins/extension/index.js +45 -41
- package/dist/es2019/plugins/help-dialog/ui/index.js +17 -1
- package/dist/es2019/plugins/hyperlink/Toolbar.js +13 -4
- package/dist/es2019/plugins/hyperlink/commands.js +9 -6
- package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +96 -91
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +3 -2
- package/dist/es2019/plugins/media/index.js +202 -198
- package/dist/es2019/plugins/media/pm-plugins/main.js +5 -4
- package/dist/es2019/plugins/media/utils/media-single.js +1 -5
- package/dist/es2019/plugins/panel/pm-plugins/keymaps.js +3 -2
- package/dist/es2019/plugins/paste/handlers.js +6 -6
- package/dist/es2019/plugins/paste/index.js +18 -14
- package/dist/es2019/plugins/paste/pm-plugins/main.js +7 -5
- package/dist/es2019/plugins/rule/commands.js +2 -2
- package/dist/es2019/plugins/rule/index.js +49 -46
- package/dist/es2019/plugins/rule/pm-plugins/input-rule.js +6 -7
- package/dist/es2019/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/es2019/plugins/text-color/index.js +49 -44
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +3 -3
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/es2019/ui/ColorPalette/index.js +2 -2
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +8 -4
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +238 -13
- package/dist/es2019/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/es2019/ui/ConfigPanel/utils.js +1 -11
- package/dist/es2019/ui/ContentStyles/index.js +2 -5
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +12 -10
- package/dist/es2019/utils/document.js +5 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +17 -6
- package/dist/esm/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/esm/create-editor/ErrorBoundary.js +1 -16
- package/dist/esm/create-editor/ReactEditorViewInternal.js +2 -2
- package/dist/esm/editor-next/editor-internal.js +2 -1
- package/dist/esm/editor-next/index.js +5 -1
- package/dist/esm/editor.js +9 -5
- package/dist/esm/keymaps/index.js +1 -1
- package/dist/esm/labs/next/internal/hooks/use-editor/index.js +4 -6
- package/dist/esm/labs/next/presets/default.js +1 -2
- package/dist/esm/plugins/card/index.js +13 -5
- package/dist/esm/plugins/card/pm-plugins/actions.js +8 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/create-analytics-queue.js +41 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/events-from-tr.js +328 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/index.js +2 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/types.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/utils.js +124 -0
- package/dist/esm/plugins/card/pm-plugins/doc.js +98 -22
- package/dist/esm/plugins/card/pm-plugins/main.js +16 -10
- package/dist/esm/plugins/card/pm-plugins/reducers.js +7 -0
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/esm/plugins/card/toolbar.js +18 -8
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +13 -9
- package/dist/esm/plugins/card/ui/EditorSmartCardEventsNext.js +191 -0
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +12 -4
- package/dist/esm/plugins/card/utils.js +4 -2
- package/dist/esm/plugins/extension/context-panel.js +3 -2
- package/dist/esm/plugins/extension/index.js +4 -1
- package/dist/esm/plugins/help-dialog/ui/index.js +29 -8
- package/dist/esm/plugins/hyperlink/Toolbar.js +13 -3
- package/dist/esm/plugins/hyperlink/commands.js +9 -5
- package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +5 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +25 -23
- package/dist/esm/plugins/media/index.js +9 -5
- package/dist/esm/plugins/media/pm-plugins/main.js +5 -4
- package/dist/esm/plugins/media/utils/media-single.js +1 -4
- package/dist/esm/plugins/panel/pm-plugins/keymaps.js +3 -2
- package/dist/esm/plugins/paste/handlers.js +6 -6
- package/dist/esm/plugins/paste/index.js +4 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +7 -5
- package/dist/esm/plugins/rule/commands.js +2 -2
- package/dist/esm/plugins/rule/index.js +5 -4
- package/dist/esm/plugins/rule/pm-plugins/input-rule.js +6 -8
- package/dist/esm/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/esm/plugins/text-color/index.js +5 -2
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +3 -4
- package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/esm/ui/ColorPalette/index.js +2 -2
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +15 -10
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +244 -19
- package/dist/esm/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/esm/ui/ConfigPanel/utils.js +0 -10
- package/dist/esm/ui/ContentStyles/index.js +2 -5
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +16 -8
- package/dist/esm/utils/document.js +5 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +3 -2
- package/dist/types/create-editor/ErrorBoundary.d.ts +2 -2
- package/dist/types/editor-next/index.d.ts +1 -0
- package/dist/types/editor.d.ts +1 -0
- package/dist/types/keymaps/index.d.ts +1 -1
- package/dist/types/labs/next/internal/hooks/use-editor/index.d.ts +2 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +1 -5
- package/dist/types/labs/next/presets/default.d.ts +2 -10
- package/dist/types/labs/next/presets/mobile.d.ts +1 -5
- package/dist/types/plugins/card/pm-plugins/actions.d.ts +2 -1
- package/dist/types/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types/plugins/card/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types/plugins/card/pm-plugins/analytics/types.d.ts +10 -0
- package/dist/types/plugins/card/pm-plugins/analytics/utils.d.ts +26 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +8 -7
- package/dist/types/plugins/card/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -2
- package/dist/types/plugins/card/pm-plugins/util/state.d.ts +3 -0
- package/dist/types/plugins/card/types.d.ts +81 -7
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +2 -1
- package/dist/types/plugins/card/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types/plugins/card/utils.d.ts +1 -1
- package/dist/types/plugins/extension/context-panel.d.ts +2 -1
- package/dist/types/plugins/extension/index.d.ts +2 -0
- package/dist/types/plugins/hyperlink/commands.d.ts +3 -2
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +2 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/index.d.ts +2 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +2 -1
- package/dist/types/plugins/media/index.d.ts +2 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -2
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
- package/dist/types/plugins/paste/index.d.ts +2 -0
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/rule/commands.d.ts +2 -1
- package/dist/types/plugins/rule/index.d.ts +5 -1
- package/dist/types/plugins/rule/pm-plugins/input-rule.d.ts +1 -1
- package/dist/types/plugins/rule/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/text-color/index.d.ts +2 -0
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +2 -0
- package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +10 -0
- package/dist/types/types/editor-appearance-component.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -0
- package/dist/types/ui/Appearance/FullPage/FullPage.d.ts +2 -0
- package/dist/types/ui/ColorPalette/index.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +3 -1
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +3 -1
- package/dist/types/ui/ConfigPanel/Fields/ColorPicker.d.ts +12 -1
- package/dist/types/ui/ConfigPanel/FormContent.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/types.d.ts +3 -0
- package/dist/types/ui/ConfigPanel/utils.d.ts +0 -1
- package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +1 -1
- package/package.json +15 -14
- package/report.api.md +10 -0
- package/dist/cjs/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -12
- package/dist/cjs/plugins/feature-flags-context/get-feature-flags.js +0 -11
- package/dist/cjs/plugins/feature-flags-context/index.js +0 -50
- package/dist/cjs/plugins/feature-flags-context/plugin-key.js +0 -9
- package/dist/es2019/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -1
- package/dist/es2019/plugins/feature-flags-context/get-feature-flags.js +0 -2
- package/dist/es2019/plugins/feature-flags-context/index.js +0 -29
- package/dist/es2019/plugins/feature-flags-context/plugin-key.js +0 -2
- package/dist/esm/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -1
- package/dist/esm/plugins/feature-flags-context/get-feature-flags.js +0 -4
- package/dist/esm/plugins/feature-flags-context/index.js +0 -40
- package/dist/esm/plugins/feature-flags-context/plugin-key.js +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +0 -1
- package/dist/types/plugins/feature-flags-context/get-feature-flags.d.ts +0 -3
- package/dist/types/plugins/feature-flags-context/index.d.ts +0 -9
- package/dist/types/plugins/feature-flags-context/plugin-key.d.ts +0 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
8
|
+
var _excluded = ["url", "display"],
|
|
9
|
+
_excluded2 = ["url", "display", "previousDisplay"],
|
|
10
|
+
_excluded3 = ["url", "display"];
|
|
11
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useEffect, useMemo } from 'react';
|
|
15
|
+
import PropTypes from 'prop-types';
|
|
16
|
+
import { useSmartLinkLifecycleAnalytics } from '@atlaskit/link-analytics';
|
|
17
|
+
import { INPUT_METHOD, ACTION } from '@atlaskit/editor-common/analytics';
|
|
18
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
19
|
+
import { registerSmartCardEventsNext } from '../pm-plugins/actions';
|
|
20
|
+
/**
|
|
21
|
+
* If the metadata is for a history event,
|
|
22
|
+
* returns undo/redo instead of instead of what fn(metadata) would have otherwise
|
|
23
|
+
* returned
|
|
24
|
+
*/
|
|
25
|
+
var withHistoryMethod = function withHistoryMethod(fn) {
|
|
26
|
+
return function (metadata) {
|
|
27
|
+
var isUndo = metadata.isUndo,
|
|
28
|
+
isRedo = metadata.isRedo;
|
|
29
|
+
if (isUndo) {
|
|
30
|
+
return 'undo';
|
|
31
|
+
}
|
|
32
|
+
if (isRedo) {
|
|
33
|
+
return 'redo';
|
|
34
|
+
}
|
|
35
|
+
return fn(metadata);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
var getMethod = withHistoryMethod(function (_ref) {
|
|
39
|
+
var inputMethod = _ref.inputMethod,
|
|
40
|
+
sourceEvent = _ref.sourceEvent;
|
|
41
|
+
/**
|
|
42
|
+
* If sourceEvent is present, don't provide a custom method
|
|
43
|
+
*/
|
|
44
|
+
if (sourceEvent) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
switch (inputMethod) {
|
|
48
|
+
case INPUT_METHOD.CLIPBOARD:
|
|
49
|
+
return 'editor_paste';
|
|
50
|
+
case INPUT_METHOD.FLOATING_TB:
|
|
51
|
+
return 'editor_floatingToolbar';
|
|
52
|
+
case INPUT_METHOD.AUTO_DETECT:
|
|
53
|
+
return 'editor_type';
|
|
54
|
+
default:
|
|
55
|
+
return 'unknown';
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var getUpdateType = withHistoryMethod(function (_ref2) {
|
|
59
|
+
var action = _ref2.action,
|
|
60
|
+
sourceEvent = _ref2.sourceEvent;
|
|
61
|
+
/**
|
|
62
|
+
* If sourceEvent is present, don't provide a custom method
|
|
63
|
+
*/
|
|
64
|
+
if (sourceEvent) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
switch (action) {
|
|
68
|
+
case ACTION.CHANGED_TYPE:
|
|
69
|
+
return 'display_update';
|
|
70
|
+
case ACTION.UPDATED:
|
|
71
|
+
return 'link_update';
|
|
72
|
+
default:
|
|
73
|
+
return 'unknown';
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
var getDeleteType = withHistoryMethod(function (_ref3) {
|
|
77
|
+
var action = _ref3.action;
|
|
78
|
+
if (action === ACTION.UNLINK) {
|
|
79
|
+
return 'unlink';
|
|
80
|
+
}
|
|
81
|
+
return 'delete';
|
|
82
|
+
});
|
|
83
|
+
var getSourceEventFromMetadata = function getSourceEventFromMetadata(metadata) {
|
|
84
|
+
return metadata.sourceEvent instanceof UIAnalyticsEvent ? metadata.sourceEvent : null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Set display category as `link` if not displaying the link as a smart card
|
|
89
|
+
*/
|
|
90
|
+
var displayCategoryFromDisplay = function displayCategoryFromDisplay(display) {
|
|
91
|
+
if (display === 'url') {
|
|
92
|
+
return 'link';
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Binds the @atlaskit/link-analytics callbacks
|
|
98
|
+
* to the editor card plugin state events callbacks interfaces
|
|
99
|
+
*/
|
|
100
|
+
export var EventsBinding = function EventsBinding(_ref4) {
|
|
101
|
+
var editorView = _ref4.editorView;
|
|
102
|
+
/**
|
|
103
|
+
* These callbacks internally use window.requestIdleCallback/requestAnimationFrame
|
|
104
|
+
* to defer any heavy operations involving network
|
|
105
|
+
*
|
|
106
|
+
* The callbacks themselves should not be deferred, they should be called syncronously the moment
|
|
107
|
+
* the events take place.
|
|
108
|
+
*/
|
|
109
|
+
var _useSmartLinkLifecycl = useSmartLinkLifecycleAnalytics(),
|
|
110
|
+
linkCreated = _useSmartLinkLifecycl.linkCreated,
|
|
111
|
+
linkUpdated = _useSmartLinkLifecycl.linkUpdated,
|
|
112
|
+
linkDeleted = _useSmartLinkLifecycl.linkDeleted;
|
|
113
|
+
var events = useMemo(function () {
|
|
114
|
+
return {
|
|
115
|
+
created: function created(_ref5) {
|
|
116
|
+
var url = _ref5.url,
|
|
117
|
+
display = _ref5.display,
|
|
118
|
+
metadata = _objectWithoutProperties(_ref5, _excluded);
|
|
119
|
+
linkCreated({
|
|
120
|
+
url: url,
|
|
121
|
+
displayCategory: displayCategoryFromDisplay(display)
|
|
122
|
+
}, getSourceEventFromMetadata(metadata), {
|
|
123
|
+
display: display,
|
|
124
|
+
creationMethod: getMethod(metadata)
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
updated: function updated(_ref6) {
|
|
128
|
+
var url = _ref6.url,
|
|
129
|
+
display = _ref6.display,
|
|
130
|
+
previousDisplay = _ref6.previousDisplay,
|
|
131
|
+
metadata = _objectWithoutProperties(_ref6, _excluded2);
|
|
132
|
+
linkUpdated({
|
|
133
|
+
url: url,
|
|
134
|
+
displayCategory: displayCategoryFromDisplay(display)
|
|
135
|
+
}, getSourceEventFromMetadata(metadata), {
|
|
136
|
+
display: display,
|
|
137
|
+
previousDisplay: previousDisplay,
|
|
138
|
+
updateMethod: getMethod(metadata),
|
|
139
|
+
updateType: getUpdateType(metadata)
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
deleted: function deleted(_ref7) {
|
|
143
|
+
var url = _ref7.url,
|
|
144
|
+
display = _ref7.display,
|
|
145
|
+
metadata = _objectWithoutProperties(_ref7, _excluded3);
|
|
146
|
+
linkDeleted({
|
|
147
|
+
url: url,
|
|
148
|
+
displayCategory: displayCategoryFromDisplay(display)
|
|
149
|
+
}, getSourceEventFromMetadata(metadata), {
|
|
150
|
+
display: display,
|
|
151
|
+
deleteMethod: getMethod(metadata),
|
|
152
|
+
deleteType: getDeleteType(metadata)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}, [linkCreated, linkUpdated, linkDeleted]);
|
|
157
|
+
useEffect(function () {
|
|
158
|
+
editorView.dispatch(registerSmartCardEventsNext(events)(editorView.state.tr));
|
|
159
|
+
}, [events, editorView]);
|
|
160
|
+
return null;
|
|
161
|
+
};
|
|
162
|
+
export var EditorSmartCardEventsNext = /*#__PURE__*/function (_React$PureComponent) {
|
|
163
|
+
_inherits(EditorSmartCardEventsNext, _React$PureComponent);
|
|
164
|
+
var _super = _createSuper(EditorSmartCardEventsNext);
|
|
165
|
+
function EditorSmartCardEventsNext() {
|
|
166
|
+
_classCallCheck(this, EditorSmartCardEventsNext);
|
|
167
|
+
return _super.apply(this, arguments);
|
|
168
|
+
}
|
|
169
|
+
_createClass(EditorSmartCardEventsNext, [{
|
|
170
|
+
key: "render",
|
|
171
|
+
value: function render() {
|
|
172
|
+
var cardContext = this.context.contextAdapter.card;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The analytics hook needs to be able to communicate with the card context
|
|
176
|
+
* If we can't access it, don't mount the event bindings
|
|
177
|
+
* This effectively entirely disables all tracking behaviour
|
|
178
|
+
*/
|
|
179
|
+
if (!cardContext) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
183
|
+
value: cardContext.value
|
|
184
|
+
}, /*#__PURE__*/React.createElement(EventsBinding, this.props));
|
|
185
|
+
}
|
|
186
|
+
}]);
|
|
187
|
+
return EditorSmartCardEventsNext;
|
|
188
|
+
}(React.PureComponent);
|
|
189
|
+
_defineProperty(EditorSmartCardEventsNext, "contextTypes", {
|
|
190
|
+
contextAdapter: PropTypes.object
|
|
191
|
+
});
|
|
@@ -5,14 +5,18 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
13
|
import PropTypes from 'prop-types';
|
|
11
14
|
import { Fragment } from 'prosemirror-model';
|
|
12
15
|
import React from 'react';
|
|
13
16
|
import nodeNames from '../../../messages';
|
|
14
17
|
import { isSupportedInParent } from '../../../utils/nodes';
|
|
15
18
|
import { messages } from '../messages';
|
|
19
|
+
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
16
20
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
17
21
|
import { getButtonGroupOption } from './link-toolbar-button-group-options';
|
|
18
22
|
import { LinkToolbarButtonGroup } from './LinkToolbarButtonGroup';
|
|
@@ -67,9 +71,9 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
67
71
|
};
|
|
68
72
|
var options = [{
|
|
69
73
|
title: intl.formatMessage(messages.url),
|
|
70
|
-
onClick:
|
|
71
|
-
|
|
72
|
-
},
|
|
74
|
+
onClick: commandWithMetadata(changeSelectedCardToLink(url, url, true), {
|
|
75
|
+
action: ACTION.CHANGED_TYPE
|
|
76
|
+
}),
|
|
73
77
|
selected: !currentAppearance,
|
|
74
78
|
testId: 'url-appearance'
|
|
75
79
|
}, {
|
|
@@ -95,7 +99,11 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
95
99
|
return /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
|
|
96
100
|
key: "link-toolbar-button-group",
|
|
97
101
|
options: options.map(function (option) {
|
|
98
|
-
return getButtonGroupOption(intl, dispatchCommand, option)
|
|
102
|
+
return getButtonGroupOption(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
|
|
103
|
+
onClick: commandWithMetadata(option.onClick, {
|
|
104
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
105
|
+
})
|
|
106
|
+
}));
|
|
99
107
|
})
|
|
100
108
|
});
|
|
101
109
|
});
|
|
@@ -2,7 +2,7 @@ import { NodeSelection } from 'prosemirror-state';
|
|
|
2
2
|
import { Slice, Fragment } from 'prosemirror-model';
|
|
3
3
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
4
4
|
import { mapChildren } from '../../utils/slice';
|
|
5
|
-
import { isSupportedInParent } from '
|
|
5
|
+
import { isSupportedInParent } from '../../utils/nodes';
|
|
6
6
|
export var appearanceForNodeType = function appearanceForNodeType(spec) {
|
|
7
7
|
if (spec.name === 'inlineCard') {
|
|
8
8
|
return 'inline';
|
|
@@ -14,7 +14,9 @@ export var appearanceForNodeType = function appearanceForNodeType(spec) {
|
|
|
14
14
|
return;
|
|
15
15
|
};
|
|
16
16
|
export var selectedCardAppearance = function selectedCardAppearance(state) {
|
|
17
|
-
|
|
17
|
+
if (state.selection instanceof NodeSelection) {
|
|
18
|
+
return appearanceForNodeType(state.selection.node.type);
|
|
19
|
+
}
|
|
18
20
|
};
|
|
19
21
|
export var titleUrlPairFromNode = function titleUrlPairFromNode(node) {
|
|
20
22
|
var attrs = node.attrs;
|
|
@@ -25,7 +25,7 @@ var areParametersEqual = function areParametersEqual(firstParameters, secondPara
|
|
|
25
25
|
}
|
|
26
26
|
return firstParameters === secondParameters;
|
|
27
27
|
};
|
|
28
|
-
export var getContextPanel = function getContextPanel(allowAutoSave) {
|
|
28
|
+
export var getContextPanel = function getContextPanel(allowAutoSave, featureFlags) {
|
|
29
29
|
return function (state) {
|
|
30
30
|
var nodeWithPos = getSelectedExtension(state, true);
|
|
31
31
|
|
|
@@ -132,7 +132,8 @@ export var getContextPanel = function getContextPanel(allowAutoSave) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}, _callee2, null, [[1, 6]]);
|
|
135
|
-
}))
|
|
135
|
+
})),
|
|
136
|
+
featureFlags: featureFlags
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
});
|
|
@@ -5,7 +5,10 @@ import { createPlugin as createUniqueIdPlugin } from './pm-plugins/unique-id';
|
|
|
5
5
|
import { getToolbarConfig } from './toolbar';
|
|
6
6
|
import { getContextPanel } from './context-panel';
|
|
7
7
|
var extensionPlugin = function extensionPlugin() {
|
|
8
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
8
9
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
11
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
9
12
|
return {
|
|
10
13
|
name: 'extension',
|
|
11
14
|
nodes: function nodes() {
|
|
@@ -45,7 +48,7 @@ var extensionPlugin = function extensionPlugin() {
|
|
|
45
48
|
},
|
|
46
49
|
pluginsOptions: {
|
|
47
50
|
floatingToolbar: getToolbarConfig(options.breakoutEnabled),
|
|
48
|
-
contextPanel: getContextPanel(options.allowAutoSave)
|
|
51
|
+
contextPanel: getContextPanel(options.allowAutoSave, featureFlags)
|
|
49
52
|
}
|
|
50
53
|
};
|
|
51
54
|
};
|
|
@@ -70,8 +70,24 @@ var messages = defineMessages({
|
|
|
70
70
|
description: 'Name of a feature, which let you insert items quickly.'
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
var navigationKeymaps = function navigationKeymaps(_ref) {
|
|
74
74
|
var formatMessage = _ref.formatMessage;
|
|
75
|
+
return [{
|
|
76
|
+
name: formatMessage(toolbarMessages.navigateToEditorToolbar),
|
|
77
|
+
type: 'navigation',
|
|
78
|
+
keymap: function keymap() {
|
|
79
|
+
return keymaps.navToEditorToolbar;
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
name: formatMessage(toolbarMessages.navigateToFloatingToolbar),
|
|
83
|
+
type: 'navigation',
|
|
84
|
+
keymap: function keymap() {
|
|
85
|
+
return keymaps.navToFloatingToolbar;
|
|
86
|
+
}
|
|
87
|
+
}];
|
|
88
|
+
};
|
|
89
|
+
export var formatting = function formatting(_ref2) {
|
|
90
|
+
var formatMessage = _ref2.formatMessage;
|
|
75
91
|
return [{
|
|
76
92
|
name: formatMessage(toolbarMessages.bold),
|
|
77
93
|
type: 'strong',
|
|
@@ -335,8 +351,8 @@ export var formatting = function formatting(_ref) {
|
|
|
335
351
|
}];
|
|
336
352
|
};
|
|
337
353
|
var shortcutNamesWithoutKeymap = ['emoji', 'mention', 'quickInsert'];
|
|
338
|
-
var otherFormatting = function otherFormatting(
|
|
339
|
-
var formatMessage =
|
|
354
|
+
var otherFormatting = function otherFormatting(_ref3) {
|
|
355
|
+
var formatMessage = _ref3.formatMessage;
|
|
340
356
|
return [{
|
|
341
357
|
name: formatMessage(toolbarMessages.clearFormatting),
|
|
342
358
|
type: 'clearFormatting',
|
|
@@ -378,8 +394,8 @@ var imageAutoFormat = {
|
|
|
378
394
|
}, ""));
|
|
379
395
|
}
|
|
380
396
|
};
|
|
381
|
-
var quickInsertAutoFormat = function quickInsertAutoFormat(
|
|
382
|
-
var formatMessage =
|
|
397
|
+
var quickInsertAutoFormat = function quickInsertAutoFormat(_ref4) {
|
|
398
|
+
var formatMessage = _ref4.formatMessage;
|
|
383
399
|
return {
|
|
384
400
|
name: formatMessage(messages.quickInsert),
|
|
385
401
|
type: 'quickInsert',
|
|
@@ -401,7 +417,7 @@ export var getSupportedFormatting = function getSupportedFormatting(schema, intl
|
|
|
401
417
|
var supportedBySchema = formatting(intl).filter(function (format) {
|
|
402
418
|
return schema.nodes[format.type] || schema.marks[format.type];
|
|
403
419
|
});
|
|
404
|
-
return [].concat(_toConsumableArray(supportedBySchema), _toConsumableArray(imageEnabled ? [imageAutoFormat] : []), _toConsumableArray(quickInsertEnabled ? [quickInsertAutoFormat(intl)] : []), _toConsumableArray(otherFormatting(intl)));
|
|
420
|
+
return [].concat(_toConsumableArray(navigationKeymaps(intl)), _toConsumableArray(supportedBySchema), _toConsumableArray(imageEnabled ? [imageAutoFormat] : []), _toConsumableArray(quickInsertEnabled ? [quickInsertAutoFormat(intl)] : []), _toConsumableArray(otherFormatting(intl)));
|
|
405
421
|
};
|
|
406
422
|
export var getComponentFromKeymap = function getComponentFromKeymap(keymap) {
|
|
407
423
|
var keyParts = getKeyParts(keymap);
|
|
@@ -420,6 +436,11 @@ export var getComponentFromKeymap = function getComponentFromKeymap(keymap) {
|
|
|
420
436
|
css: codeMd,
|
|
421
437
|
key: "".concat(keyParts, "-").concat(index)
|
|
422
438
|
}, part);
|
|
439
|
+
} else if (['f9', 'f10'].indexOf(part.toLowerCase()) >= 0) {
|
|
440
|
+
return jsx("span", {
|
|
441
|
+
css: codeLg,
|
|
442
|
+
key: "".concat(keyParts, "-").concat(index)
|
|
443
|
+
}, part);
|
|
423
444
|
}
|
|
424
445
|
return jsx("span", {
|
|
425
446
|
css: codeSm,
|
|
@@ -427,8 +448,8 @@ export var getComponentFromKeymap = function getComponentFromKeymap(keymap) {
|
|
|
427
448
|
}, part.toUpperCase());
|
|
428
449
|
}));
|
|
429
450
|
};
|
|
430
|
-
var ModalHeader = injectIntl(function (
|
|
431
|
-
var formatMessage =
|
|
451
|
+
var ModalHeader = injectIntl(function (_ref5) {
|
|
452
|
+
var formatMessage = _ref5.intl.formatMessage;
|
|
432
453
|
var _useModal = useModal(),
|
|
433
454
|
onClose = _useModal.onClose;
|
|
434
455
|
return jsx("div", {
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { stateKey } from './pm-plugins/main';
|
|
7
7
|
import { removeLink, editInsertedLink, updateLink, insertLinkWithAnalytics } from './commands';
|
|
8
8
|
import HyperlinkAddToolbar from './ui/HyperlinkAddToolbar';
|
|
9
|
+
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
9
10
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
10
11
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
11
12
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
@@ -14,7 +15,7 @@ import { linkToolbarMessages as linkToolbarCommonMessages, linkMessages } from '
|
|
|
14
15
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
15
16
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '../../ui/LinkSearch/ToolbarComponents';
|
|
16
17
|
import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
|
|
17
|
-
import { addAnalytics, ACTION_SUBJECT_ID } from '../analytics';
|
|
18
|
+
import { addAnalytics, ACTION_SUBJECT_ID, ACTION, INPUT_METHOD } from '../analytics';
|
|
18
19
|
import { buildVisitedLinkPayload, buildOpenedSettingsPayload } from '../../utils/linking-utils';
|
|
19
20
|
/* type guard for edit links */
|
|
20
21
|
function isEditLink(linkMark) {
|
|
@@ -155,7 +156,9 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags) {
|
|
|
155
156
|
}, {
|
|
156
157
|
id: 'editor.link.unlink',
|
|
157
158
|
type: 'button',
|
|
158
|
-
onClick: removeLink(pos),
|
|
159
|
+
onClick: commandWithMetadata(removeLink(pos), {
|
|
160
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
161
|
+
}),
|
|
159
162
|
selected: false,
|
|
160
163
|
title: labelUnlink,
|
|
161
164
|
icon: UnlinkIcon,
|
|
@@ -214,7 +217,14 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags) {
|
|
|
214
217
|
var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
215
218
|
var displayText = arguments.length > 2 ? arguments[2] : undefined;
|
|
216
219
|
var inputMethod = arguments.length > 3 ? arguments[3] : undefined;
|
|
217
|
-
|
|
220
|
+
var analytic = arguments.length > 4 ? arguments[4] : undefined;
|
|
221
|
+
var isEdit = isEditLink(activeLinkMark);
|
|
222
|
+
var action = isEdit ? ACTION.UPDATED : ACTION.INSERTED;
|
|
223
|
+
var command = isEdit ? commandWithMetadata(updateLink(href, displayText || title, activeLinkMark.pos), {
|
|
224
|
+
action: action,
|
|
225
|
+
sourceEvent: analytic
|
|
226
|
+
}) : insertLinkWithAnalytics(inputMethod, activeLinkMark.from, activeLinkMark.to, href, title, displayText, !!(options !== null && options !== void 0 && (_options$cardOptions = options.cardOptions) !== null && _options$cardOptions !== void 0 && _options$cardOptions.provider), analytic);
|
|
227
|
+
command(view.state, view.dispatch, view);
|
|
218
228
|
view.focus();
|
|
219
229
|
}
|
|
220
230
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
4
5
|
import { normalizeUrl } from './utils';
|
|
5
6
|
import { stateKey, LinkAction } from './pm-plugins/main';
|
|
6
7
|
import { Selection } from 'prosemirror-state';
|
|
@@ -85,7 +86,7 @@ export function updateLink(href, text, pos, to) {
|
|
|
85
86
|
return true;
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
|
-
export function insertLink(from, to, incomingHref, incomingTitle, displayText, source) {
|
|
89
|
+
export function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent) {
|
|
89
90
|
return function (state, dispatch) {
|
|
90
91
|
var link = state.schema.marks.link;
|
|
91
92
|
var tr = state.tr;
|
|
@@ -109,7 +110,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
109
110
|
}));
|
|
110
111
|
tr.setSelection(Selection.near(tr.doc.resolve(markEnd)));
|
|
111
112
|
if (!displayText || displayText === incomingHref) {
|
|
112
|
-
queueCardsFromChangedTr(state, tr, source, false);
|
|
113
|
+
queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent);
|
|
113
114
|
}
|
|
114
115
|
tr.setMeta(stateKey, {
|
|
115
116
|
type: LinkAction.HIDE_TOOLBAR
|
|
@@ -130,17 +131,20 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
130
131
|
}
|
|
131
132
|
export var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, title, displayText) {
|
|
132
133
|
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
134
|
+
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
133
135
|
// If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
|
|
134
136
|
if (cardsAvailable && !title && !displayText) {
|
|
135
|
-
return insertLink(from, to, href, title, displayText, inputMethod);
|
|
137
|
+
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent);
|
|
136
138
|
}
|
|
137
|
-
return withAnalytics(getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
|
|
139
|
+
return withAnalytics(getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
138
140
|
};
|
|
139
141
|
export var insertLinkWithAnalyticsMobileNative = function insertLinkWithAnalyticsMobileNative(inputMethod, from, to, href, title, displayText) {
|
|
140
142
|
return withAnalytics(getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
|
|
141
143
|
};
|
|
142
144
|
export function removeLink(pos) {
|
|
143
|
-
return setLinkHref('', pos)
|
|
145
|
+
return commandWithMetadata(setLinkHref('', pos), {
|
|
146
|
+
action: ACTION.UNLINK
|
|
147
|
+
});
|
|
144
148
|
}
|
|
145
149
|
export function editInsertedLink() {
|
|
146
150
|
return function (state, dispatch) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
2
3
|
import { createRule, createPlugin } from '../../../utils/input-rules';
|
|
3
4
|
import { findFilepaths, isLinkInMatches, LinkMatcher, normalizeUrl } from '../utils';
|
|
4
5
|
import { INPUT_METHOD, addAnalytics } from '../../analytics';
|
|
@@ -39,6 +40,9 @@ export function createLinkInputRule(regexp) {
|
|
|
39
40
|
if (to === end) {
|
|
40
41
|
tr.insertText(' ');
|
|
41
42
|
}
|
|
43
|
+
addLinkMetadata(state.selection, tr, {
|
|
44
|
+
inputMethod: INPUT_METHOD.AUTO_DETECT
|
|
45
|
+
});
|
|
42
46
|
if (skipAnalytics) {
|
|
43
47
|
return tr;
|
|
44
48
|
}
|
|
@@ -17,13 +17,13 @@ import { EditorLinkPicker } from '../EditorLinkPicker';
|
|
|
17
17
|
* Wraps around the editor's onSubmit handler so that the plugin can interface with the link picker
|
|
18
18
|
*/
|
|
19
19
|
var onSubmitInterface = function onSubmitInterface(onSubmit) {
|
|
20
|
-
return function (_ref) {
|
|
20
|
+
return function (_ref, analytic) {
|
|
21
21
|
var url = _ref.url,
|
|
22
22
|
title = _ref.title,
|
|
23
23
|
displayText = _ref.displayText,
|
|
24
24
|
rawUrl = _ref.rawUrl,
|
|
25
25
|
meta = _ref.meta;
|
|
26
|
-
onSubmit(url, title !== null && title !== void 0 ? title : rawUrl, displayText || undefined, meta.inputMethod === 'manual' ? INPUT_METHOD.MANUAL : INPUT_METHOD.TYPEAHEAD);
|
|
26
|
+
onSubmit(url, title !== null && title !== void 0 ? title : rawUrl, displayText || undefined, meta.inputMethod === 'manual' ? INPUT_METHOD.MANUAL : INPUT_METHOD.TYPEAHEAD, analytic);
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
var HyperlinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -50,7 +50,6 @@ export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
|
50
50
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
51
51
|
export { default as historyPlugin } from './history';
|
|
52
52
|
export { default as captionPlugin } from './caption';
|
|
53
|
-
export { default as featureFlagsContextPlugin } from './feature-flags-context';
|
|
54
53
|
export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
55
54
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
56
55
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
@@ -40,7 +40,10 @@ function handleInsertBlockType(name) {
|
|
|
40
40
|
return insertBlockTypesWithAnalytics(name, INPUT_METHOD.TOOLBAR);
|
|
41
41
|
}
|
|
42
42
|
var insertBlockPlugin = function insertBlockPlugin() {
|
|
43
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
43
44
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
45
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
46
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
44
47
|
return {
|
|
45
48
|
name: 'insertBlock',
|
|
46
49
|
primaryToolbarComponent: function primaryToolbarComponent(_ref) {
|
|
@@ -122,7 +125,8 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
122
125
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
123
126
|
replacePlusMenuWithElementBrowser: options.replacePlusMenuWithElementBrowser,
|
|
124
127
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
125
|
-
showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S
|
|
128
|
+
showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S,
|
|
129
|
+
featureFlags: featureFlags
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
});
|
|
@@ -250,22 +250,24 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
250
250
|
};
|
|
251
251
|
});
|
|
252
252
|
_defineProperty(_assertThisInitialized(_this), "insertHorizontalRule", function (inputMethod) {
|
|
253
|
+
var _this$props2 = _this.props,
|
|
254
|
+
_this$props2$editorVi = _this$props2.editorView,
|
|
255
|
+
state = _this$props2$editorVi.state,
|
|
256
|
+
dispatch = _this$props2$editorVi.dispatch,
|
|
257
|
+
featureFlags = _this$props2.featureFlags;
|
|
258
|
+
return insertHorizontalRule(inputMethod, featureFlags)(state, dispatch);
|
|
259
|
+
});
|
|
260
|
+
_defineProperty(_assertThisInitialized(_this), "insertExpand", function () {
|
|
253
261
|
var _this$props$editorVie2 = _this.props.editorView,
|
|
254
262
|
state = _this$props$editorVie2.state,
|
|
255
263
|
dispatch = _this$props$editorVie2.dispatch;
|
|
256
|
-
return insertHorizontalRule(inputMethod)(state, dispatch);
|
|
257
|
-
});
|
|
258
|
-
_defineProperty(_assertThisInitialized(_this), "insertExpand", function () {
|
|
259
|
-
var _this$props$editorVie3 = _this.props.editorView,
|
|
260
|
-
state = _this$props$editorVie3.state,
|
|
261
|
-
dispatch = _this$props$editorVie3.dispatch;
|
|
262
264
|
return insertExpand(state, dispatch);
|
|
263
265
|
});
|
|
264
266
|
_defineProperty(_assertThisInitialized(_this), "insertBlockType", function (itemName) {
|
|
265
267
|
return function () {
|
|
266
|
-
var _this$
|
|
267
|
-
editorView = _this$
|
|
268
|
-
onInsertBlockType = _this$
|
|
268
|
+
var _this$props3 = _this.props,
|
|
269
|
+
editorView = _this$props3.editorView,
|
|
270
|
+
onInsertBlockType = _this$props3.onInsertBlockType;
|
|
269
271
|
var state = editorView.state,
|
|
270
272
|
dispatch = editorView.dispatch;
|
|
271
273
|
onInsertBlockType(itemName)(state, dispatch);
|
|
@@ -284,11 +286,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
284
286
|
_defineProperty(_assertThisInitialized(_this), "onItemActivated", function (_ref2) {
|
|
285
287
|
var item = _ref2.item,
|
|
286
288
|
inputMethod = _ref2.inputMethod;
|
|
287
|
-
var _this$
|
|
288
|
-
editorView = _this$
|
|
289
|
-
editorActions = _this$
|
|
290
|
-
handleImageUpload = _this$
|
|
291
|
-
expandEnabled = _this$
|
|
289
|
+
var _this$props4 = _this.props,
|
|
290
|
+
editorView = _this$props4.editorView,
|
|
291
|
+
editorActions = _this$props4.editorActions,
|
|
292
|
+
handleImageUpload = _this$props4.handleImageUpload,
|
|
293
|
+
expandEnabled = _this$props4.expandEnabled;
|
|
292
294
|
|
|
293
295
|
// need to do this before inserting nodes so scrollIntoView works properly
|
|
294
296
|
if (!editorView.hasFocus()) {
|
|
@@ -404,12 +406,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
404
406
|
key: "renderPopup",
|
|
405
407
|
value: function renderPopup() {
|
|
406
408
|
var emojiPickerOpen = this.state.emojiPickerOpen;
|
|
407
|
-
var _this$
|
|
408
|
-
popupsMountPoint = _this$
|
|
409
|
-
popupsBoundariesElement = _this$
|
|
410
|
-
popupsScrollableElement = _this$
|
|
411
|
-
emojiProvider = _this$
|
|
412
|
-
replacePlusMenuWithElementBrowser = _this$
|
|
409
|
+
var _this$props5 = this.props,
|
|
410
|
+
popupsMountPoint = _this$props5.popupsMountPoint,
|
|
411
|
+
popupsBoundariesElement = _this$props5.popupsBoundariesElement,
|
|
412
|
+
popupsScrollableElement = _this$props5.popupsScrollableElement,
|
|
413
|
+
emojiProvider = _this$props5.emojiProvider,
|
|
414
|
+
replacePlusMenuWithElementBrowser = _this$props5.replacePlusMenuWithElementBrowser;
|
|
413
415
|
var dropdownEmoji = this.state.dropdownItems.some(function (_ref4) {
|
|
414
416
|
var name = _ref4.value.name;
|
|
415
417
|
return name === 'emoji';
|
|
@@ -445,9 +447,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
445
447
|
buttons = _this$state.buttons,
|
|
446
448
|
dropdownItems = _this$state.dropdownItems,
|
|
447
449
|
emojiPickerOpen = _this$state.emojiPickerOpen;
|
|
448
|
-
var _this$
|
|
449
|
-
isDisabled = _this$
|
|
450
|
-
isReducedSpacing = _this$
|
|
450
|
+
var _this$props6 = this.props,
|
|
451
|
+
isDisabled = _this$props6.isDisabled,
|
|
452
|
+
isReducedSpacing = _this$props6.isReducedSpacing;
|
|
451
453
|
if (buttons.length === 0 && dropdownItems.length === 0) {
|
|
452
454
|
return null;
|
|
453
455
|
}
|
|
@@ -22,7 +22,11 @@ import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
|
22
22
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
23
23
|
import { ReactMediaInlineNode } from './nodeviews/mediaInline';
|
|
24
24
|
export { insertMediaSingleNode } from './utils/media-single';
|
|
25
|
-
var mediaPlugin = function mediaPlugin(
|
|
25
|
+
var mediaPlugin = function mediaPlugin() {
|
|
26
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
27
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
28
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
29
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
26
30
|
return {
|
|
27
31
|
name: 'media',
|
|
28
32
|
nodes: function nodes() {
|
|
@@ -31,9 +35,9 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
31
35
|
allowMediaGroup = _ref$allowMediaGroup === void 0 ? true : _ref$allowMediaGroup,
|
|
32
36
|
_ref$allowMediaSingle = _ref.allowMediaSingle,
|
|
33
37
|
allowMediaSingle = _ref$allowMediaSingle === void 0 ? false : _ref$allowMediaSingle,
|
|
34
|
-
|
|
35
|
-
var captions = getMediaFeatureFlag('captions',
|
|
36
|
-
var allowMediaInline = getMediaFeatureFlag('mediaInline',
|
|
38
|
+
mediaFeatureFlags = _ref.featureFlags;
|
|
39
|
+
var captions = getMediaFeatureFlag('captions', mediaFeatureFlags);
|
|
40
|
+
var allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
37
41
|
var mediaSingleNode = captions ? mediaSingleWithCaption : mediaSingle;
|
|
38
42
|
return [{
|
|
39
43
|
name: 'mediaGroup',
|
|
@@ -87,7 +91,7 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
87
91
|
customDropzoneContainer: options && options.customDropzoneContainer,
|
|
88
92
|
customMediaPicker: options && options.customMediaPicker,
|
|
89
93
|
allowResizing: !!(options && options.allowResizing)
|
|
90
|
-
}, reactContext, getIntl, dispatch, options);
|
|
94
|
+
}, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour);
|
|
91
95
|
}
|
|
92
96
|
}, {
|
|
93
97
|
name: 'mediaKeymap',
|