@atlaskit/editor-core 182.0.2 → 182.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/.eslintrc.js +2 -0
- package/CHANGELOG.md +46 -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/nodeviews/mediaNodeView/media.js +7 -1
- 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/FullPage/FullPage.js +2 -4
- 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/nodeviews/mediaNodeView/media.js +9 -1
- 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/FullPage/FullPage.js +2 -4
- 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/nodeviews/mediaNodeView/media.js +7 -1
- 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/FullPage/FullPage.js +2 -4
- 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 +14 -13
- 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
|
@@ -5,13 +5,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
6
6
|
import { closeHistory } from 'prosemirror-history';
|
|
7
7
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
8
|
+
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
8
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../../../plugins/analytics';
|
|
9
10
|
import { SMART_LINK_TYPE } from '../../../plugins/analytics/types/node-events';
|
|
10
11
|
import { getLinkCreationAnalyticsEvent } from '../../../plugins/hyperlink/analytics';
|
|
11
12
|
import { nodesBetweenChanged, processRawValue } from '../../../utils';
|
|
12
13
|
import { unlinkPayload } from '../../../utils/linking-utils';
|
|
13
14
|
import { isFromCurrentDomain } from '../../hyperlink/utils';
|
|
14
|
-
import { appearanceForNodeType } from '../utils';
|
|
15
|
+
import { appearanceForNodeType, selectedCardAppearance } from '../utils';
|
|
15
16
|
import { queueCards, resolveCard } from './actions';
|
|
16
17
|
import { pluginKey } from './plugin-key';
|
|
17
18
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
@@ -46,7 +47,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
46
47
|
tr.replaceWith(pos, pos + (node.text || url).length, nodes);
|
|
47
48
|
return $pos.node($pos.depth - 1).type.name;
|
|
48
49
|
}
|
|
49
|
-
export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction
|
|
50
|
+
export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction) {
|
|
50
51
|
return function (editorState, dispatch) {
|
|
51
52
|
var state = pluginKey.getState(editorState);
|
|
52
53
|
if (!state) {
|
|
@@ -84,15 +85,22 @@ export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, car
|
|
|
84
85
|
if (state.smartLinkEvents) {
|
|
85
86
|
state.smartLinkEvents.insertSmartLink(domainName, 'inline', state.createAnalyticsEvent);
|
|
86
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* TODO:
|
|
91
|
+
* What if each request has a different source?
|
|
92
|
+
* Unlikely, but need to define behaviour.
|
|
93
|
+
* Ignore analytics event? take first? provide 'mixed' as well?
|
|
94
|
+
*/
|
|
95
|
+
var inputMethod = requests[0].source;
|
|
96
|
+
var sourceEvent = requests[0].sourceEvent;
|
|
87
97
|
addAnalytics(editorState, tr, {
|
|
88
98
|
action: analyticsAction || ACTION.INSERTED,
|
|
89
99
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
90
100
|
actionSubjectId: ACTION_SUBJECT_ID.SMART_LINK,
|
|
91
101
|
eventType: EVENT_TYPE.TRACK,
|
|
92
102
|
attributes: {
|
|
93
|
-
inputMethod:
|
|
94
|
-
unlikely, but need to define behaviour.
|
|
95
|
-
ignore analytics event? take first? provide 'mixed' as well?*/,
|
|
103
|
+
inputMethod: inputMethod,
|
|
96
104
|
nodeType: nodeType,
|
|
97
105
|
nodeContext: nodeContext,
|
|
98
106
|
fromCurrentDomain: isFromCurrentDomain(url)
|
|
@@ -101,6 +109,12 @@ export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, car
|
|
|
101
109
|
domainName: domainName
|
|
102
110
|
}
|
|
103
111
|
});
|
|
112
|
+
addLinkMetadata(editorState.selection, tr, {
|
|
113
|
+
action: analyticsAction,
|
|
114
|
+
inputMethod: inputMethod,
|
|
115
|
+
cardAction: 'RESOLVE',
|
|
116
|
+
sourceEvent: sourceEvent
|
|
117
|
+
});
|
|
104
118
|
}
|
|
105
119
|
}
|
|
106
120
|
if (dispatch) {
|
|
@@ -109,22 +123,29 @@ export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, car
|
|
|
109
123
|
return true;
|
|
110
124
|
};
|
|
111
125
|
};
|
|
112
|
-
export var handleFallbackWithAnalytics = function handleFallbackWithAnalytics(
|
|
113
|
-
return function (
|
|
114
|
-
var
|
|
115
|
-
if (!
|
|
126
|
+
export var handleFallbackWithAnalytics = function handleFallbackWithAnalytics(request) {
|
|
127
|
+
return function (state, dispatch) {
|
|
128
|
+
var cardState = pluginKey.getState(state);
|
|
129
|
+
if (!cardState) {
|
|
116
130
|
return false;
|
|
117
131
|
}
|
|
118
|
-
var tr =
|
|
119
|
-
|
|
132
|
+
var tr = state.tr;
|
|
133
|
+
if (request.source !== INPUT_METHOD.FLOATING_TB) {
|
|
134
|
+
addAnalytics(state, tr, getLinkCreationAnalyticsEvent(request.source, request.url));
|
|
135
|
+
}
|
|
136
|
+
addLinkMetadata(state.selection, tr, {
|
|
137
|
+
action: request.analyticsAction,
|
|
138
|
+
inputMethod: request.source
|
|
139
|
+
});
|
|
120
140
|
if (dispatch) {
|
|
121
|
-
dispatch(resolveCard(url)(tr));
|
|
141
|
+
dispatch(resolveCard(request.url)(tr));
|
|
122
142
|
}
|
|
123
143
|
return true;
|
|
124
144
|
};
|
|
125
145
|
};
|
|
126
|
-
export var queueCardsFromChangedTr = function queueCardsFromChangedTr(state, tr, source) {
|
|
127
|
-
var normalizeLinkText = arguments.length >
|
|
146
|
+
export var queueCardsFromChangedTr = function queueCardsFromChangedTr(state, tr, source, analyticsAction) {
|
|
147
|
+
var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
148
|
+
var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
|
|
128
149
|
var schema = state.schema;
|
|
129
150
|
var link = schema.marks.link;
|
|
130
151
|
var requests = [];
|
|
@@ -144,11 +165,52 @@ export var queueCardsFromChangedTr = function queueCardsFromChangedTr(state, tr,
|
|
|
144
165
|
pos: pos,
|
|
145
166
|
appearance: 'inline',
|
|
146
167
|
compareLinkText: normalizeLinkText,
|
|
147
|
-
source: source
|
|
168
|
+
source: source,
|
|
169
|
+
analyticsAction: analyticsAction,
|
|
170
|
+
sourceEvent: sourceEvent
|
|
148
171
|
});
|
|
149
172
|
}
|
|
150
173
|
return false;
|
|
151
174
|
});
|
|
175
|
+
addLinkMetadata(state.selection, tr, {
|
|
176
|
+
action: analyticsAction
|
|
177
|
+
});
|
|
178
|
+
return queueCards(requests)(tr);
|
|
179
|
+
};
|
|
180
|
+
export var queueCardFromChangedTr = function queueCardFromChangedTr(state, tr, source, analyticsAction) {
|
|
181
|
+
var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
182
|
+
var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
|
|
183
|
+
var previousAppearance = arguments.length > 6 ? arguments[6] : undefined;
|
|
184
|
+
var schema = state.schema;
|
|
185
|
+
var link = schema.marks.link;
|
|
186
|
+
var requests = [];
|
|
187
|
+
nodesBetweenChanged(tr, function (node, pos) {
|
|
188
|
+
if (!node.isText) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
var linkMark = node.marks.find(function (mark) {
|
|
192
|
+
return mark.type === link;
|
|
193
|
+
});
|
|
194
|
+
if (linkMark) {
|
|
195
|
+
if (!shouldReplaceLink(node, normalizeLinkText)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
requests.push({
|
|
199
|
+
url: linkMark.attrs.href,
|
|
200
|
+
pos: pos,
|
|
201
|
+
appearance: 'inline',
|
|
202
|
+
previousAppearance: previousAppearance,
|
|
203
|
+
compareLinkText: normalizeLinkText,
|
|
204
|
+
source: source,
|
|
205
|
+
analyticsAction: analyticsAction,
|
|
206
|
+
sourceEvent: sourceEvent
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
});
|
|
211
|
+
addLinkMetadata(state.selection, tr, {
|
|
212
|
+
action: analyticsAction
|
|
213
|
+
});
|
|
152
214
|
return queueCards(requests)(tr);
|
|
153
215
|
};
|
|
154
216
|
export var convertHyperlinkToSmartCard = function convertHyperlinkToSmartCard(state, source, appearance) {
|
|
@@ -161,18 +223,21 @@ export var convertHyperlinkToSmartCard = function convertHyperlinkToSmartCard(st
|
|
|
161
223
|
return mark.type === link;
|
|
162
224
|
});
|
|
163
225
|
if (linkMark) {
|
|
164
|
-
|
|
226
|
+
requests.push({
|
|
165
227
|
url: linkMark.attrs.href,
|
|
166
228
|
pos: pos,
|
|
167
229
|
appearance: appearance,
|
|
230
|
+
previousAppearance: 'url',
|
|
168
231
|
compareLinkText: normalizeLinkText,
|
|
169
232
|
source: source,
|
|
170
233
|
analyticsAction: ACTION.CHANGED_TYPE,
|
|
171
234
|
shouldReplaceLink: true
|
|
172
|
-
};
|
|
173
|
-
requests.push(request);
|
|
235
|
+
});
|
|
174
236
|
}
|
|
175
237
|
});
|
|
238
|
+
addLinkMetadata(state.selection, state.tr, {
|
|
239
|
+
action: ACTION.CHANGED_TYPE
|
|
240
|
+
});
|
|
176
241
|
return queueCards(requests)(state.tr);
|
|
177
242
|
};
|
|
178
243
|
export var changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos) {
|
|
@@ -227,14 +292,15 @@ export var changeSelectedCardToLinkFallback = function changeSelectedCardToLinkF
|
|
|
227
292
|
return true;
|
|
228
293
|
};
|
|
229
294
|
};
|
|
230
|
-
export var updateCard = function updateCard(href) {
|
|
295
|
+
export var updateCard = function updateCard(href, sourceEvent) {
|
|
231
296
|
return function (state, dispatch) {
|
|
232
297
|
var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
|
|
233
298
|
if (!selectedNode) {
|
|
234
299
|
return false;
|
|
235
300
|
}
|
|
301
|
+
var cardAppearance = selectedCardAppearance(state);
|
|
236
302
|
var tr = cardToLinkWithTransaction(state, href, href);
|
|
237
|
-
|
|
303
|
+
queueCardFromChangedTr(state, tr, INPUT_METHOD.MANUAL, ACTION.UPDATED, undefined, sourceEvent, cardAppearance);
|
|
238
304
|
if (dispatch) {
|
|
239
305
|
dispatch(tr.scrollIntoView());
|
|
240
306
|
}
|
|
@@ -268,7 +334,11 @@ export var changeSelectedCardToText = function changeSelectedCardToText(text) {
|
|
|
268
334
|
}
|
|
269
335
|
var tr = state.tr.replaceSelectionWith(state.schema.text(text), false);
|
|
270
336
|
if (dispatch) {
|
|
271
|
-
|
|
337
|
+
addLinkMetadata(state.selection, tr, {
|
|
338
|
+
action: ACTION.UNLINK
|
|
339
|
+
});
|
|
340
|
+
addAnalytics(state, tr.scrollIntoView(), unlinkPayload(ACTION_SUBJECT_ID.CARD_INLINE));
|
|
341
|
+
dispatch(tr);
|
|
272
342
|
}
|
|
273
343
|
return true;
|
|
274
344
|
};
|
|
@@ -280,8 +350,11 @@ export var setSelectedCardAppearance = function setSelectedCardAppearance(appear
|
|
|
280
350
|
if (!selectedNode) {
|
|
281
351
|
// When there is no selected node, we insert a new one
|
|
282
352
|
// and replace the existing blue link
|
|
283
|
-
var _tr = convertHyperlinkToSmartCard(state, INPUT_METHOD.
|
|
353
|
+
var _tr = convertHyperlinkToSmartCard(state, INPUT_METHOD.FLOATING_TB, appearance);
|
|
284
354
|
if (dispatch) {
|
|
355
|
+
addLinkMetadata(state.selection, _tr, {
|
|
356
|
+
action: ACTION.CHANGED_TYPE
|
|
357
|
+
});
|
|
285
358
|
dispatch(_tr.scrollIntoView());
|
|
286
359
|
}
|
|
287
360
|
return false;
|
|
@@ -318,6 +391,9 @@ export var setSelectedCardAppearance = function setSelectedCardAppearance(appear
|
|
|
318
391
|
previousType: appearanceForNodeType(selectedNode.type)
|
|
319
392
|
}
|
|
320
393
|
});
|
|
394
|
+
addLinkMetadata(state.selection, tr, {
|
|
395
|
+
action: ACTION.CHANGED_TYPE
|
|
396
|
+
});
|
|
321
397
|
if (dispatch) {
|
|
322
398
|
dispatch(tr.scrollIntoView());
|
|
323
399
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import rafSchedule from 'raf-schd';
|
|
3
4
|
import { getInlineNodeViewProducer } from '../../../nodeviews/getInlineNodeViewProducer';
|
|
@@ -8,9 +9,12 @@ import { pluginKey } from './plugin-key';
|
|
|
8
9
|
import reducer from './reducers';
|
|
9
10
|
import { handleProvider, resolveWithProvider } from './util/resolve';
|
|
10
11
|
import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
|
|
12
|
+
import { createAnalyticsQueue, eventsFromTransaction } from './analytics';
|
|
11
13
|
export { pluginKey } from './plugin-key';
|
|
12
14
|
export var createPlugin = function createPlugin(options) {
|
|
13
15
|
return function (pmPluginFactoryParams) {
|
|
16
|
+
var lpAnalyticsEventsNext = pmPluginFactoryParams.featureFlags.lpAnalyticsEventsNext;
|
|
17
|
+
var analyticsQueue = createAnalyticsQueue(!!lpAnalyticsEventsNext);
|
|
14
18
|
var editorAppearance = options.editorAppearance,
|
|
15
19
|
platform = options.platform,
|
|
16
20
|
allowResizing = options.allowResizing,
|
|
@@ -27,25 +31,31 @@ export var createPlugin = function createPlugin(options) {
|
|
|
27
31
|
cards: [],
|
|
28
32
|
showLinkingToolbar: false,
|
|
29
33
|
smartLinkEvents: undefined,
|
|
34
|
+
smartLinkEventsNext: undefined,
|
|
30
35
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
31
36
|
editorAppearance: editorAppearance
|
|
32
37
|
};
|
|
33
38
|
},
|
|
34
|
-
apply: function apply(tr, pluginState) {
|
|
39
|
+
apply: function apply(tr, pluginState, prevEditorState) {
|
|
35
40
|
// Update all the positions of outstanding requests and
|
|
36
41
|
// cards in the plugin state.
|
|
37
42
|
var pluginStateWithUpdatedPos = getPluginStateWithUpdatedPos(pluginState, tr);
|
|
43
|
+
|
|
38
44
|
// apply any actions
|
|
39
45
|
var meta = tr.getMeta(pluginKey);
|
|
46
|
+
var events = eventsFromTransaction(tr, prevEditorState);
|
|
47
|
+
analyticsQueue.push.apply(analyticsQueue, _toConsumableArray(events));
|
|
40
48
|
if (meta) {
|
|
41
|
-
var
|
|
42
|
-
|
|
49
|
+
var nextState = reducer(pluginStateWithUpdatedPos, meta);
|
|
50
|
+
if (!pluginState.smartLinkEventsNext && nextState.smartLinkEventsNext) {
|
|
51
|
+
analyticsQueue.setCallbacks(nextState.smartLinkEventsNext);
|
|
52
|
+
}
|
|
53
|
+
return nextState;
|
|
43
54
|
}
|
|
44
55
|
return pluginStateWithUpdatedPos;
|
|
45
56
|
}
|
|
46
57
|
},
|
|
47
58
|
view: function view(_view) {
|
|
48
|
-
var outstandingRequests = {};
|
|
49
59
|
var subscriptionHandler = function subscriptionHandler(name, provider) {
|
|
50
60
|
return handleProvider(name, provider, _view);
|
|
51
61
|
};
|
|
@@ -71,19 +81,15 @@ export var createPlugin = function createPlugin(options) {
|
|
|
71
81
|
* other tasks as per common implementations of the JavaScript event loop in browsers.
|
|
72
82
|
*/
|
|
73
83
|
var invoke = rafSchedule(function () {
|
|
74
|
-
return resolveWithProvider(view,
|
|
84
|
+
return resolveWithProvider(view, provider, request, options);
|
|
75
85
|
});
|
|
76
86
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
77
87
|
invoke();
|
|
78
88
|
});
|
|
79
89
|
}
|
|
90
|
+
analyticsQueue.flush();
|
|
80
91
|
},
|
|
81
92
|
destroy: function destroy() {
|
|
82
|
-
// Cancel all outstanding requests
|
|
83
|
-
Object.keys(outstandingRequests).forEach(function (url) {
|
|
84
|
-
return Promise.reject(outstandingRequests[url]);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
93
|
// Cancel any outstanding raf callbacks.
|
|
88
94
|
rafCancellationCallbacks.forEach(function (cancellationCallback) {
|
|
89
95
|
return cancellationCallback();
|
|
@@ -34,6 +34,11 @@ var registerEvents = function registerEvents(state, action) {
|
|
|
34
34
|
smartLinkEvents: action.smartLinkEvents
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
+
var registerEventsNext = function registerEventsNext(state, action) {
|
|
38
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
39
|
+
smartLinkEventsNext: action.smartLinkEvents
|
|
40
|
+
});
|
|
41
|
+
};
|
|
37
42
|
var setLinkToolbar = function setLinkToolbar(state, action) {
|
|
38
43
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
39
44
|
showLinkingToolbar: action.type === 'SHOW_LINK_TOOLBAR'
|
|
@@ -51,6 +56,8 @@ export default (function (state, action) {
|
|
|
51
56
|
return register(state, action);
|
|
52
57
|
case 'REGISTER_EVENTS':
|
|
53
58
|
return registerEvents(state, action);
|
|
59
|
+
case 'REGISTER_EVENTS_NEXT':
|
|
60
|
+
return registerEventsNext(state, action);
|
|
54
61
|
case 'SHOW_LINK_TOOLBAR':
|
|
55
62
|
case 'HIDE_LINK_TOOLBAR':
|
|
56
63
|
return setLinkToolbar(state, action);
|
|
@@ -5,18 +5,14 @@ import { replaceQueuedUrlWithCard, handleFallbackWithAnalytics } from '../doc';
|
|
|
5
5
|
// ============================================================================ //
|
|
6
6
|
// Used for all interactions with the EditorCardProvider.
|
|
7
7
|
// ============================================================================ //
|
|
8
|
-
export var resolveWithProvider = function resolveWithProvider(view,
|
|
8
|
+
export var resolveWithProvider = function resolveWithProvider(view, provider, request, options) {
|
|
9
9
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
10
10
|
var shouldForceAppearance =
|
|
11
11
|
// This flag is set to true only in one place atm:
|
|
12
12
|
// packages/editor/editor-core/src/plugins/card/pm-plugins/doc.ts @ convertHyperlinkToSmartCard
|
|
13
13
|
// Which is used when user switching from URL to smart link appearance.
|
|
14
14
|
!!request.shouldReplaceLink;
|
|
15
|
-
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance).then(
|
|
16
|
-
delete outstandingRequests[request.url];
|
|
17
|
-
return resolvedCard;
|
|
18
|
-
}).then(handleResolved(view, request, options), handleRejected(view, request));
|
|
19
|
-
outstandingRequests[request.url] = handleResolve;
|
|
15
|
+
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance).then(handleResolved(view, request, options), handleRejected(view, request));
|
|
20
16
|
return handleResolve;
|
|
21
17
|
};
|
|
22
18
|
var updateCardType = function updateCardType(resolvedCard, options) {
|
|
@@ -37,7 +33,7 @@ var handleResolved = function handleResolved(view, request, options) {
|
|
|
37
33
|
};
|
|
38
34
|
var handleRejected = function handleRejected(view, request) {
|
|
39
35
|
return function () {
|
|
40
|
-
handleFallbackWithAnalytics(request
|
|
36
|
+
handleFallbackWithAnalytics(request)(view.state, view.dispatch);
|
|
41
37
|
};
|
|
42
38
|
};
|
|
43
39
|
|
|
@@ -14,6 +14,7 @@ import { linkToolbarMessages, linkMessages } from '../../messages';
|
|
|
14
14
|
import commonMessages from '../../messages';
|
|
15
15
|
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
16
16
|
import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
17
|
+
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
17
18
|
import { pluginKey } from './pm-plugins/main';
|
|
18
19
|
import { richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
19
20
|
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
@@ -24,7 +25,7 @@ import { messages } from './messages';
|
|
|
24
25
|
import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
|
|
25
26
|
import { buildOpenedSettingsPayload, buildVisitedLinkPayload } from '../../utils/linking-utils';
|
|
26
27
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
|
|
27
|
-
export var removeCard = function
|
|
28
|
+
export var removeCard = commandWithMetadata(function (state, dispatch) {
|
|
28
29
|
if (!(state.selection instanceof NodeSelection)) {
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
@@ -43,7 +44,9 @@ export var removeCard = function removeCard(state, dispatch) {
|
|
|
43
44
|
dispatch(addAnalytics(state, removeSelectedNode(state.tr), payload));
|
|
44
45
|
}
|
|
45
46
|
return true;
|
|
46
|
-
}
|
|
47
|
+
}, {
|
|
48
|
+
action: ACTION.DELETED
|
|
49
|
+
});
|
|
47
50
|
export var visitCardLink = function visitCardLink(state, dispatch) {
|
|
48
51
|
if (!(state.selection instanceof NodeSelection)) {
|
|
49
52
|
return false;
|
|
@@ -130,14 +133,21 @@ var unlinkCard = function unlinkCard(node, state) {
|
|
|
130
133
|
var displayInfo = displayInfoForCard(node, findCardInfo(state));
|
|
131
134
|
var text = displayInfo.title || displayInfo.url;
|
|
132
135
|
if (text) {
|
|
133
|
-
return changeSelectedCardToText(text)
|
|
136
|
+
return commandWithMetadata(changeSelectedCardToText(text), {
|
|
137
|
+
action: ACTION.UNLINK
|
|
138
|
+
});
|
|
134
139
|
}
|
|
135
140
|
return function () {
|
|
136
141
|
return false;
|
|
137
142
|
};
|
|
138
143
|
};
|
|
139
|
-
var buildAlignmentOptions = function buildAlignmentOptions(state, intl) {
|
|
140
|
-
return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, true, true);
|
|
144
|
+
var buildAlignmentOptions = function buildAlignmentOptions(state, intl, cardOptions) {
|
|
145
|
+
return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
|
|
146
|
+
};
|
|
147
|
+
var withToolbarMetadata = function withToolbarMetadata(command) {
|
|
148
|
+
return commandWithMetadata(command, {
|
|
149
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
150
|
+
});
|
|
141
151
|
};
|
|
142
152
|
var generateToolbarItems = function generateToolbarItems(state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker) {
|
|
143
153
|
return function (node) {
|
|
@@ -208,10 +218,10 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
208
218
|
onFocus: hoverDecoration(node.type, true),
|
|
209
219
|
onBlur: hoverDecoration(node.type, false),
|
|
210
220
|
title: intl.formatMessage(commonMessages.remove),
|
|
211
|
-
onClick: removeCard
|
|
221
|
+
onClick: withToolbarMetadata(removeCard)
|
|
212
222
|
}]);
|
|
213
223
|
if (currentAppearance === 'embed') {
|
|
214
|
-
var alignmentOptions = buildAlignmentOptions(state, intl);
|
|
224
|
+
var alignmentOptions = buildAlignmentOptions(state, intl, cardOptions);
|
|
215
225
|
if (alignmentOptions.length) {
|
|
216
226
|
alignmentOptions.push({
|
|
217
227
|
type: 'separator'
|
|
@@ -256,7 +266,7 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
|
|
|
256
266
|
type: 'button',
|
|
257
267
|
title: intl.formatMessage(linkToolbarMessages.unlink),
|
|
258
268
|
icon: UnlinkIcon,
|
|
259
|
-
onClick: unlinkCard(node, state)
|
|
269
|
+
onClick: withToolbarMetadata(unlinkCard(node, state))
|
|
260
270
|
}, {
|
|
261
271
|
type: 'separator'
|
|
262
272
|
}] : [];
|
|
@@ -8,16 +8,17 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
8
8
|
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
9
|
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; } }
|
|
10
10
|
import React from 'react';
|
|
11
|
+
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
12
|
+
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
11
13
|
import HyperlinkToolbar from '../../hyperlink/ui/HyperlinkAddToolbar';
|
|
12
14
|
import { showLinkToolbar, hideLinkToolbar as _hideLinkToolbar } from '../pm-plugins/actions';
|
|
13
|
-
import { addAnalytics, INPUT_METHOD } from '../../analytics';
|
|
15
|
+
import { addAnalytics, INPUT_METHOD, ACTION } from '../../analytics';
|
|
14
16
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '../../../ui/LinkSearch/ToolbarComponents';
|
|
15
17
|
import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
|
|
16
18
|
import { findCardInfo, displayInfoForCard } from '../utils';
|
|
17
19
|
import { NodeSelection } from 'prosemirror-state';
|
|
18
20
|
import { buildEditLinkPayload } from '../../../utils/linking-utils';
|
|
19
21
|
import { forceFocusSelector } from '../../floating-toolbar/pm-plugins/force-focus';
|
|
20
|
-
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
21
22
|
import { linkToolbarMessages } from '../../../messages';
|
|
22
23
|
var HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkToolbar);
|
|
23
24
|
export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
@@ -81,10 +82,10 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
81
82
|
,
|
|
82
83
|
invokeMethod: INPUT_METHOD.FLOATING_TB,
|
|
83
84
|
featureFlags: featureFlags,
|
|
84
|
-
onSubmit: function onSubmit(href, title, displayText) {
|
|
85
|
+
onSubmit: function onSubmit(href, title, displayText, _, analytic) {
|
|
85
86
|
_this2.hideLinkToolbar();
|
|
86
87
|
if (_onSubmit) {
|
|
87
|
-
_onSubmit(href, displayText || title);
|
|
88
|
+
_onSubmit(href, displayText || title, analytic);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
});
|
|
@@ -126,19 +127,22 @@ export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref) {
|
|
|
126
127
|
text: displayInfo.title || '',
|
|
127
128
|
node: node,
|
|
128
129
|
featureFlags: featureFlags,
|
|
129
|
-
onSubmit: function onSubmit(newHref, newText) {
|
|
130
|
+
onSubmit: function onSubmit(newHref, newText, analytic) {
|
|
130
131
|
var urlChanged = newHref !== displayInfo.url;
|
|
131
132
|
var titleChanged = newText !== displayInfo.title;
|
|
132
133
|
|
|
133
134
|
// If the title is changed in a smartlink, convert to standard blue hyperlink
|
|
134
135
|
// (even if the url was also changed) - we don't want to lose the custom title.
|
|
135
136
|
if (titleChanged) {
|
|
136
|
-
return changeSelectedCardToLink(newText, newHref)
|
|
137
|
-
|
|
137
|
+
return commandWithMetadata(changeSelectedCardToLink(newText, newHref), {
|
|
138
|
+
action: ACTION.UPDATED,
|
|
139
|
+
sourceEvent: analytic
|
|
140
|
+
})(view.state, view.dispatch);
|
|
141
|
+
}
|
|
142
|
+
if (urlChanged) {
|
|
138
143
|
// If *only* the url is changed in a smart link, reresolve
|
|
139
|
-
return updateCard(newHref)(view.state, view.dispatch);
|
|
144
|
+
return updateCard(newHref, analytic)(view.state, view.dispatch);
|
|
140
145
|
}
|
|
141
|
-
return;
|
|
142
146
|
}
|
|
143
147
|
});
|
|
144
148
|
}
|