@atlaskit/editor-core 150.0.0 → 151.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +4 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/collab-edit/ui/to-avatar.js +4 -8
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +8 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +4 -2
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/collab-edit/ui/to-avatar.js +2 -6
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +4 -2
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/collab-edit/ui/to-avatar.js +4 -8
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +3 -1
- package/dist/types/plugins/analytics/analytics-queue.d.ts +1 -1
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/plugins/quick-insert/index.d.ts +1 -1
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +20 -17
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
2
|
import { isPerformanceObserverAvailable, isPerformanceAPIAvailable, getAnalyticsEventSeverity } from '@atlaskit/editor-common';
|
|
3
|
+
import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
|
|
3
4
|
import { ACTION, ACTION_SUBJECT, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE } from '../../analytics';
|
|
4
5
|
import { getParticipantsCount } from '../../collab-edit/get-participants-count';
|
|
5
6
|
import { countNodes } from '../../../utils/count-nodes';
|
|
6
7
|
import { getContextIdentifier } from './context-identifier';
|
|
7
8
|
import { setInteractionType } from '../utils/frozen-editor';
|
|
8
9
|
import { getTimeSince } from '../../../utils/performance/get-performance-timing';
|
|
10
|
+
export const frozenEditorPluginKey = new PluginKey('frozenEditor');
|
|
9
11
|
const DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
|
|
10
12
|
const DEFAULT_SLOW_THRESHOLD = 300;
|
|
11
13
|
export const DEFAULT_FREEZE_THRESHOLD = 600;
|
|
@@ -38,7 +40,7 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, allowCountNod
|
|
|
38
40
|
});
|
|
39
41
|
};
|
|
40
42
|
|
|
41
|
-
export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking) => {
|
|
43
|
+
export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
|
|
42
44
|
let keystrokeCount = 0;
|
|
43
45
|
let interactionType;
|
|
44
46
|
|
|
@@ -54,6 +56,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking) =
|
|
|
54
56
|
const severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
55
57
|
const severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
56
58
|
return new Plugin({
|
|
59
|
+
key: frozenEditorPluginKey,
|
|
57
60
|
props: isPerformanceAPIAvailable() ? {
|
|
58
61
|
handleTextInput(view) {
|
|
59
62
|
const {
|
|
@@ -65,49 +68,74 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking) =
|
|
|
65
68
|
interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
const experienceStore = ufo ? ExperienceStore.getInstance(view) : undefined;
|
|
72
|
+
const trackTyping = samplingRate && ++keystrokeCount === samplingRate;
|
|
73
|
+
|
|
74
|
+
if (trackTyping) {
|
|
75
|
+
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.start(EditorExperience.typing);
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
requestAnimationFrame(() => {
|
|
69
79
|
const diff = getTimeSince(now);
|
|
70
80
|
|
|
71
|
-
if (
|
|
72
|
-
var _getContextIdentifier2;
|
|
73
|
-
|
|
81
|
+
if (diff > slowThreshold) {
|
|
74
82
|
const nodesCount = allowCountNodes ? countNodes(view.state) : {};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
|
|
84
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
|
|
85
|
+
var _getContextIdentifier2;
|
|
86
|
+
|
|
87
|
+
dispatchAnalyticsEvent({
|
|
88
|
+
action: ACTION.SLOW_INPUT,
|
|
89
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
90
|
+
attributes: {
|
|
91
|
+
time: diff,
|
|
92
|
+
nodeSize: state.doc.nodeSize,
|
|
93
|
+
...nodesCount,
|
|
94
|
+
participants: getParticipantsCount(state),
|
|
95
|
+
objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId
|
|
96
|
+
},
|
|
97
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
98
|
+
});
|
|
91
99
|
}
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.addMetadata(EditorExperience.typing, {
|
|
102
|
+
slowInput: true
|
|
103
|
+
});
|
|
94
104
|
}
|
|
95
105
|
|
|
96
|
-
if (
|
|
97
|
-
var
|
|
106
|
+
if (trackTyping) {
|
|
107
|
+
var _getContextIdentifier4;
|
|
98
108
|
|
|
99
109
|
const nodesCount = allowCountNodes ? countNodes(view.state) : {};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
keystrokeCount = 0;
|
|
111
|
+
const severity = shouldTrackSeverity ? getAnalyticsEventSeverity(diff, severityThresholdNormal, severityThresholdDegraded) : undefined;
|
|
112
|
+
|
|
113
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
|
|
114
|
+
var _getContextIdentifier3;
|
|
115
|
+
|
|
116
|
+
const payload = {
|
|
117
|
+
action: ACTION.INPUT_PERF_SAMPLING,
|
|
118
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
119
|
+
attributes: {
|
|
120
|
+
time: diff,
|
|
121
|
+
nodeSize: state.doc.nodeSize,
|
|
122
|
+
...nodesCount,
|
|
123
|
+
participants: getParticipantsCount(state),
|
|
124
|
+
objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId,
|
|
125
|
+
severity
|
|
126
|
+
},
|
|
127
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
128
|
+
};
|
|
129
|
+
dispatchAnalyticsEvent(payload);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, {
|
|
133
|
+
nodeSize: state.doc.nodeSize,
|
|
134
|
+
...nodesCount,
|
|
135
|
+
participants: getParticipantsCount(state),
|
|
136
|
+
objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
|
|
137
|
+
time: diff,
|
|
138
|
+
severity
|
|
111
139
|
});
|
|
112
140
|
}
|
|
113
141
|
});
|
|
@@ -14,7 +14,8 @@ export const BlockTypeMenuItem = styled.div`
|
|
|
14
14
|
margin-top: 0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
${props =>
|
|
17
|
+
${props => // TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
|
|
18
|
+
props.selected ? `${props.tagName} { color: white !important; }` : ''};
|
|
18
19
|
`;
|
|
19
20
|
export const KeyboardShortcut = styled(Shortcut)`
|
|
20
21
|
${props => props.selected ? `color: ${N400};` : ''}
|
|
@@ -28,13 +28,18 @@ const cardPlugin = options => {
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
pmPlugins() {
|
|
31
|
-
var _options$allowResizin, _options$useAlternati;
|
|
31
|
+
var _options$allowBlockCa, _options$allowResizin, _options$useAlternati;
|
|
32
32
|
|
|
33
|
+
const allowBlockCards = (_options$allowBlockCa = options.allowBlockCards) !== null && _options$allowBlockCa !== void 0 ? _options$allowBlockCa : true;
|
|
33
34
|
const allowResizing = (_options$allowResizin = options.allowResizing) !== null && _options$allowResizin !== void 0 ? _options$allowResizin : true;
|
|
34
35
|
const useAlternativePreloader = (_options$useAlternati = options.useAlternativePreloader) !== null && _options$useAlternati !== void 0 ? _options$useAlternati : true;
|
|
35
36
|
return [{
|
|
36
37
|
name: 'card',
|
|
37
|
-
plugin: createPlugin(
|
|
38
|
+
plugin: createPlugin({ ...options,
|
|
39
|
+
allowBlockCards,
|
|
40
|
+
allowResizing,
|
|
41
|
+
useAlternativePreloader
|
|
42
|
+
})
|
|
38
43
|
}];
|
|
39
44
|
},
|
|
40
45
|
|
|
@@ -234,6 +234,7 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
234
234
|
const lineLength = this.getLineLength(view, pos, widthStateLineLength);
|
|
235
235
|
const containerWidth = isRichMediaInsideOfBlockNode(view, pos) ? lineLength : widthStateWidth;
|
|
236
236
|
const smartCard = /*#__PURE__*/React.createElement(SmartCard, {
|
|
237
|
+
key: url,
|
|
237
238
|
url: url,
|
|
238
239
|
appearance: "embed",
|
|
239
240
|
onClick: this.onClick,
|
|
@@ -8,12 +8,19 @@ import { EmbedCard } from '../nodeviews/embedCard';
|
|
|
8
8
|
import { BlockCard } from '../nodeviews/blockCard';
|
|
9
9
|
import { InlineCard } from '../nodeviews/inlineCard';
|
|
10
10
|
export { pluginKey } from './plugin-key';
|
|
11
|
-
export const createPlugin =
|
|
11
|
+
export const createPlugin = options => ({
|
|
12
12
|
portalProviderAPI,
|
|
13
13
|
eventDispatcher,
|
|
14
14
|
providerFactory,
|
|
15
15
|
dispatchAnalyticsEvent
|
|
16
16
|
}) => {
|
|
17
|
+
const {
|
|
18
|
+
platform,
|
|
19
|
+
allowResizing,
|
|
20
|
+
useAlternativePreloader,
|
|
21
|
+
fullWidthMode,
|
|
22
|
+
createAnalyticsEvent
|
|
23
|
+
} = options;
|
|
17
24
|
return new Plugin({
|
|
18
25
|
state: {
|
|
19
26
|
init() {
|
|
@@ -73,7 +80,7 @@ export const createPlugin = (platform, allowResizing, useAlternativePreloader, f
|
|
|
73
80
|
* By using this approach, the browser is free to schedule the resolution of the promises below in between rendering/network/
|
|
74
81
|
* other tasks as per common implementations of the JavaScript event loop in browsers.
|
|
75
82
|
*/
|
|
76
|
-
const invoke = rafSchedule(() => resolveWithProvider(view, outstandingRequests, provider, request));
|
|
83
|
+
const invoke = rafSchedule(() => resolveWithProvider(view, outstandingRequests, provider, request, options));
|
|
77
84
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
78
85
|
invoke();
|
|
79
86
|
});
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { setProvider } from '../actions';
|
|
2
|
-
import { replaceQueuedUrlWithCard, handleFallbackWithAnalytics } from '../doc';
|
|
2
|
+
import { replaceQueuedUrlWithCard, handleFallbackWithAnalytics } from '../doc';
|
|
3
|
+
// ============================================================================ //
|
|
3
4
|
// ============================== PROVIDER UTILS ============================== //
|
|
4
5
|
// ============================================================================ //
|
|
5
6
|
// Used for all interactions with the EditorCardProvider.
|
|
6
7
|
// ============================================================================ //
|
|
7
|
-
|
|
8
|
-
export const resolveWithProvider = (view, outstandingRequests, provider, request) => {
|
|
8
|
+
export const resolveWithProvider = (view, outstandingRequests, provider, request, options) => {
|
|
9
9
|
const handleResolve = provider.resolve(request.url, request.appearance).then(resolvedCard => {
|
|
10
10
|
delete outstandingRequests[request.url];
|
|
11
11
|
return resolvedCard;
|
|
12
|
-
}).then(handleResolved(view, request), handleRejected(view, request));
|
|
12
|
+
}).then(handleResolved(view, request, options), handleRejected(view, request));
|
|
13
13
|
outstandingRequests[request.url] = handleResolve;
|
|
14
14
|
return handleResolve;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const updateCardType = (resolvedCard, options) => {
|
|
18
|
+
if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds) {
|
|
19
|
+
resolvedCard.type = 'inlineCard';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleResolved = (view, request, options) => resolvedCard => {
|
|
24
|
+
updateCardType(resolvedCard, options);
|
|
18
25
|
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction)(view.state, view.dispatch);
|
|
19
26
|
return resolvedCard;
|
|
20
27
|
};
|
|
@@ -41,7 +41,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false) => (state, {
|
|
|
41
41
|
alias: lang.alias
|
|
42
42
|
})); // If language is not undefined search for it in the value and then search in the aliases
|
|
43
43
|
|
|
44
|
-
const defaultValue = language ? options.find(option => option.value === language) || options.find(option => option.alias.includes(language)) :
|
|
44
|
+
const defaultValue = language ? options.find(option => option.value === language) || options.find(option => option.alias.includes(language)) : null;
|
|
45
45
|
const languageSelect = {
|
|
46
46
|
id: 'editor.codeBlock.languageOptions',
|
|
47
47
|
type: 'select',
|
|
@@ -12,10 +12,6 @@ const toAvatar = participant => ({
|
|
|
12
12
|
})
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const a = aRaw;
|
|
17
|
-
const b = bRaw;
|
|
15
|
+
export default memoizeOne(toAvatar, function participantEquals([a], [b]) {
|
|
18
16
|
return a.name === b.name && a.avatar === b.avatar && a.sessionId === b.sessionId;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default memoizeOne(toAvatar, participantEquals);
|
|
17
|
+
});
|
|
@@ -5,6 +5,8 @@ import { EmojiSharedCssClassName } from '@atlaskit/editor-common';
|
|
|
5
5
|
import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
export const emojiStyles = css`
|
|
7
7
|
.${EmojiSharedCssClassName.EMOJI_CONTAINER} {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
|
|
8
10
|
.${EmojiSharedCssClassName.EMOJI_NODE} {
|
|
9
11
|
cursor: pointer;
|
|
10
12
|
|
|
@@ -97,7 +97,6 @@ export const createContextIdentifierProviderHandler = view => async (name, provi
|
|
|
97
97
|
|
|
98
98
|
const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, useLongPressSelection = false, options = {}) => {
|
|
99
99
|
const state = createPluginState(dispatch, {
|
|
100
|
-
layout: 'default',
|
|
101
100
|
showEditButton: false,
|
|
102
101
|
showContextPanel: false
|
|
103
102
|
});
|
|
@@ -155,14 +154,12 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
155
154
|
const showEditButton = shouldShowEditButton(extensionHandler, extensionProvider);
|
|
156
155
|
const updateExtension = getUpdateExtensionPromise(view, extensionHandler, extensionProvider).catch(() => {// do nothing;
|
|
157
156
|
});
|
|
158
|
-
const layout = selectedExtension ? node.attrs.layout : 'default';
|
|
159
157
|
updateState({
|
|
160
158
|
localId: node.attrs.localId,
|
|
161
159
|
showContextPanel: false,
|
|
162
160
|
element: newElement,
|
|
163
161
|
showEditButton,
|
|
164
|
-
updateExtension
|
|
165
|
-
layout
|
|
162
|
+
updateExtension
|
|
166
163
|
})(state, dispatch);
|
|
167
164
|
} // New DOM element doesn't necessarily mean it's a new Node
|
|
168
165
|
else if (element !== newElement) {
|
|
@@ -41,30 +41,35 @@ const isLayoutSupported = (state, selectedExtNode) => {
|
|
|
41
41
|
return !!((selectedExtNode.node.type === bodiedExtension || selectedExtNode.node.type === extension && !hasParentNodeOfType([bodiedExtension, table, expand].filter(Boolean))(selection)) && !hasParentNodeOfType([layoutSection])(selection));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const breakoutOptions = (state, formatMessage,
|
|
45
|
-
const nodeWithPos = getSelectedExtension(state, true);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
const breakoutOptions = (state, formatMessage, breakoutEnabled) => {
|
|
45
|
+
const nodeWithPos = getSelectedExtension(state, true); // we should only return breakout options when breakouts are enabled and the node supports them
|
|
46
|
+
|
|
47
|
+
if (nodeWithPos && breakoutEnabled && isLayoutSupported(state, nodeWithPos)) {
|
|
48
|
+
const {
|
|
49
|
+
layout
|
|
50
|
+
} = nodeWithPos.node.attrs;
|
|
51
|
+
return [{
|
|
52
|
+
type: 'button',
|
|
53
|
+
icon: CenterIcon,
|
|
54
|
+
onClick: updateExtensionLayout('default'),
|
|
55
|
+
selected: layout === 'default',
|
|
56
|
+
title: formatMessage(commonMessages.layoutFixedWidth)
|
|
57
|
+
}, {
|
|
58
|
+
type: 'button',
|
|
59
|
+
icon: WideIcon,
|
|
60
|
+
onClick: updateExtensionLayout('wide'),
|
|
61
|
+
selected: layout === 'wide',
|
|
62
|
+
title: formatMessage(commonMessages.layoutWide)
|
|
63
|
+
}, {
|
|
64
|
+
type: 'button',
|
|
65
|
+
icon: FullWidthIcon,
|
|
66
|
+
onClick: updateExtensionLayout('full-width'),
|
|
67
|
+
selected: layout === 'full-width',
|
|
68
|
+
title: formatMessage(commonMessages.layoutFullWidth)
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return [];
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
const editButton = (formatMessage, extensionState) => {
|
|
@@ -99,7 +104,7 @@ export const getToolbarConfig = (breakoutEnabled = true) => (state, intl) => {
|
|
|
99
104
|
if (extensionState && !extensionState.showContextPanel && extensionState.element) {
|
|
100
105
|
const nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension];
|
|
101
106
|
const editButtonArray = editButton(formatMessage, extensionState);
|
|
102
|
-
const breakoutButtonArray = breakoutOptions(state, formatMessage,
|
|
107
|
+
const breakoutButtonArray = breakoutOptions(state, formatMessage, breakoutEnabled);
|
|
103
108
|
return {
|
|
104
109
|
title: 'Extension floating controls',
|
|
105
110
|
getDomRef: () => extensionState.element.parentElement || undefined,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { normalizeFeatureFlags } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
2
|
-
|
|
2
|
+
import { browser } from '@atlaskit/editor-common';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms EditorProps to an FeatureFlags object,
|
|
5
5
|
* which is used by both current and archv3 editors.
|
|
6
6
|
*/
|
|
7
|
+
|
|
7
8
|
export function createFeatureFlagsFromProps(props) {
|
|
8
|
-
var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25;
|
|
9
|
+
var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
|
|
12
|
+
return { ...normalizedFeatureFlags,
|
|
11
13
|
newInsertionBehaviour: props.allowNewInsertionBehaviour,
|
|
12
14
|
interactiveExpand: typeof props.allowExpand === 'boolean' ? props.allowExpand : Boolean(props.allowExpand && props.allowExpand.allowInteractiveExpand !== false),
|
|
13
15
|
placeholderBracketHint: !!props.placeholderBracketHint,
|
|
@@ -32,6 +34,8 @@ export function createFeatureFlagsFromProps(props) {
|
|
|
32
34
|
errorBoundaryDocStructure: Boolean(typeof ((_props$featureFlags18 = props.featureFlags) === null || _props$featureFlags18 === void 0 ? void 0 : _props$featureFlags18.useErrorBoundaryDocStructure) === 'boolean' ? !!((_props$featureFlags19 = props.featureFlags) !== null && _props$featureFlags19 !== void 0 && _props$featureFlags19.useErrorBoundaryDocStructure) : false),
|
|
33
35
|
synchronyErrorDocStructure: Boolean(typeof ((_props$featureFlags20 = props.featureFlags) === null || _props$featureFlags20 === void 0 ? void 0 : _props$featureFlags20.synchronyErrorDocStructure) === 'boolean' ? !!((_props$featureFlags21 = props.featureFlags) !== null && _props$featureFlags21 !== void 0 && _props$featureFlags21.synchronyErrorDocStructure) : false),
|
|
34
36
|
enableViewUpdateSubscription: Boolean(typeof ((_props$featureFlags22 = props.featureFlags) === null || _props$featureFlags22 === void 0 ? void 0 : _props$featureFlags22.enableViewUpdateSubscription) === 'boolean' ? !!((_props$featureFlags23 = props.featureFlags) !== null && _props$featureFlags23 !== void 0 && _props$featureFlags23.enableViewUpdateSubscription) : false),
|
|
35
|
-
collabAvatarScroll: Boolean(typeof ((_props$featureFlags24 = props.featureFlags) === null || _props$featureFlags24 === void 0 ? void 0 : _props$featureFlags24.collabAvatarScroll) === 'boolean' ? !!((_props$featureFlags25 = props.featureFlags) !== null && _props$featureFlags25 !== void 0 && _props$featureFlags25.collabAvatarScroll) : false)
|
|
37
|
+
collabAvatarScroll: Boolean(typeof ((_props$featureFlags24 = props.featureFlags) === null || _props$featureFlags24 === void 0 ? void 0 : _props$featureFlags24.collabAvatarScroll) === 'boolean' ? !!((_props$featureFlags25 = props.featureFlags) !== null && _props$featureFlags25 !== void 0 && _props$featureFlags25.collabAvatarScroll) : false),
|
|
38
|
+
ufo: Boolean(typeof ((_props$featureFlags26 = props.featureFlags) === null || _props$featureFlags26 === void 0 ? void 0 : _props$featureFlags26.ufo) === 'boolean' ? !!((_props$featureFlags27 = props.featureFlags) !== null && _props$featureFlags27 !== void 0 && _props$featureFlags27.ufo) : false),
|
|
39
|
+
codeBlockSyntaxHighlighting: Boolean(typeof normalizedFeatureFlags.codeBlockSyntaxHighlighting === 'boolean' ? !!normalizedFeatureFlags.codeBlockSyntaxHighlighting && !browser.safari : false)
|
|
36
40
|
};
|
|
37
41
|
}
|
|
@@ -71,12 +71,17 @@ class Find extends React.Component {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
_defineProperty(this, "handleFindChange", event =>
|
|
74
|
+
_defineProperty(this, "handleFindChange", event => {
|
|
75
75
|
this.updateFindValue(event.target.value);
|
|
76
|
-
})
|
|
76
|
+
});
|
|
77
77
|
|
|
78
78
|
_defineProperty(this, "updateFindValue", value => {
|
|
79
|
-
this.
|
|
79
|
+
this.setState({
|
|
80
|
+
localFindText: value
|
|
81
|
+
});
|
|
82
|
+
this.skipWhileComposing(() => {
|
|
83
|
+
this.props.onFind(value);
|
|
84
|
+
});
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
_defineProperty(this, "handleFindKeyDown", event => this.skipWhileComposing(() => {
|
|
@@ -153,7 +158,13 @@ class Find extends React.Component {
|
|
|
153
158
|
});
|
|
154
159
|
this.closeIcon = /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
155
160
|
label: this.closeFindReplaceDialog
|
|
156
|
-
});
|
|
161
|
+
}); // We locally manage the value of the input inside this component in order to support compositions.
|
|
162
|
+
// This requires some additional work inside componentDidUpdate to ensure we support changes that
|
|
163
|
+
// occur to this value which do not originate from this component.
|
|
164
|
+
|
|
165
|
+
this.state = {
|
|
166
|
+
localFindText: this.props.findText || ''
|
|
167
|
+
};
|
|
157
168
|
}
|
|
158
169
|
|
|
159
170
|
componentDidMount() {
|
|
@@ -162,7 +173,17 @@ class Find extends React.Component {
|
|
|
162
173
|
}
|
|
163
174
|
|
|
164
175
|
componentDidUpdate() {
|
|
165
|
-
this.focusFindTextfield();
|
|
176
|
+
this.focusFindTextfield(); // If the external prop findText changes and we aren't in a composition we should update to the
|
|
177
|
+
// use the external prop value.
|
|
178
|
+
//
|
|
179
|
+
// An example of where this may happen is when a find occurs through the user selecting some text
|
|
180
|
+
// and pressing Mod-f.
|
|
181
|
+
|
|
182
|
+
if (!this.isComposing && this.props.findText !== this.state.localFindText) {
|
|
183
|
+
this.setState({
|
|
184
|
+
localFindText: this.props.findText || ''
|
|
185
|
+
});
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
render() {
|
|
@@ -183,7 +204,7 @@ class Find extends React.Component {
|
|
|
183
204
|
name: "find",
|
|
184
205
|
appearance: "none",
|
|
185
206
|
placeholder: this.find,
|
|
186
|
-
value:
|
|
207
|
+
value: this.state.localFindText,
|
|
187
208
|
ref: this.findTextfieldRef,
|
|
188
209
|
autoComplete: "off",
|
|
189
210
|
onChange: this.handleFindChange,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keymap } from 'prosemirror-keymap';
|
|
2
|
+
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
2
3
|
import * as keymaps from '../../../keymaps';
|
|
3
|
-
import { getLinkMatch } from '../utils';
|
|
4
4
|
import { stateKey } from '../pm-plugins/main';
|
|
5
5
|
import { showLinkToolbar, hideLinkToolbar } from '../commands';
|
|
6
6
|
import { queueCards } from '../../card/pm-plugins/actions';
|
|
@@ -83,7 +83,8 @@ const mapActivityProviderResultToLinkSearchItemData = ({
|
|
|
83
83
|
container,
|
|
84
84
|
iconUrl,
|
|
85
85
|
url,
|
|
86
|
-
lastViewedDate: viewedTimestamp ? new Date(viewedTimestamp) : undefined
|
|
86
|
+
lastViewedDate: viewedTimestamp ? new Date(viewedTimestamp) : undefined,
|
|
87
|
+
prefetch: true
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
const mapSearchProviderResultToLinkSearchItemData = ({
|
|
@@ -99,7 +100,8 @@ const mapSearchProviderResultToLinkSearchItemData = ({
|
|
|
99
100
|
name: title,
|
|
100
101
|
url,
|
|
101
102
|
lastUpdatedDate: updatedTimestamp ? new Date(updatedTimestamp) : undefined,
|
|
102
|
-
icon: contentType && mapContentTypeToIcon[contentType] || defaultIcon
|
|
103
|
+
icon: contentType && mapContentTypeToIcon[contentType] || defaultIcon,
|
|
104
|
+
prefetch: false
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
@@ -344,7 +346,7 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
if (interaction === 'click' || this.isUrlPopulatedWithSelectedItem()) {
|
|
347
|
-
var _pluginState$searchSe3;
|
|
349
|
+
var _pluginState$searchSe3, _selectedItem$prefetc;
|
|
348
350
|
|
|
349
351
|
/**
|
|
350
352
|
* When it's a mouse click even or the selectedItem.url matches displayUrl, we think
|
|
@@ -361,7 +363,8 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
361
363
|
trigger: interaction,
|
|
362
364
|
resultCount: items.length,
|
|
363
365
|
selectedResultId: selectedItem.objectId,
|
|
364
|
-
selectedRelativePosition: selectedIndex
|
|
366
|
+
selectedRelativePosition: selectedIndex,
|
|
367
|
+
prefetch: (_selectedItem$prefetc = selectedItem.prefetch) !== null && _selectedItem$prefetc !== void 0 ? _selectedItem$prefetc : false
|
|
365
368
|
},
|
|
366
369
|
eventType: EVENT_TYPE.UI
|
|
367
370
|
});
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import LinkifyIt from 'linkify-it';
|
|
2
1
|
import { mapSlice } from '../../utils/slice';
|
|
3
|
-
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
4
|
-
export const LINK_REGEXP = /(https?|ftp):\/\/[^\s]+/;
|
|
5
|
-
const linkify = LinkifyIt();
|
|
6
|
-
linkify.add('sourcetree:', 'http:');
|
|
7
|
-
const tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
|
8
|
-
const tlds2Char = 'a[cdefgilmnoqrtuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrtuvwxyz]|n[acefgilopruz]|om|p[aefghkmnrtw]|qa|r[eosuw]|s[abcdegijklmnrtuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
|
|
9
|
-
tlds.push(tlds2Char);
|
|
10
|
-
linkify.tlds(tlds, false);
|
|
11
|
-
export function getLinkMatch(str) {
|
|
12
|
-
if (!str) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let match = linkifyMatch(str);
|
|
17
|
-
|
|
18
|
-
if (!match.length) {
|
|
19
|
-
match = linkify.match(str);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return match && match[0];
|
|
23
|
-
}
|
|
2
|
+
import { isSafeUrl, linkify, normalizeUrl as normaliseLinkHref } from '@atlaskit/adf-schema';
|
|
24
3
|
/**
|
|
25
4
|
* Instance of class LinkMatcher are used in autoformatting in place of Regex.
|
|
26
5
|
* Hence it has been made similar to regex with an exec method.
|
|
@@ -81,8 +60,7 @@ export function normalizeUrl(url) {
|
|
|
81
60
|
return url;
|
|
82
61
|
}
|
|
83
62
|
|
|
84
|
-
|
|
85
|
-
return match && match.url || '';
|
|
63
|
+
return normaliseLinkHref(url);
|
|
86
64
|
}
|
|
87
65
|
export function linkifyContent(schema) {
|
|
88
66
|
return slice => mapSlice(slice, (node, parent) => {
|
|
@@ -148,38 +126,4 @@ function findLinkMatches(text) {
|
|
|
148
126
|
}
|
|
149
127
|
|
|
150
128
|
return matches;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const linkifyMatch = text => {
|
|
154
|
-
const matches = [];
|
|
155
|
-
|
|
156
|
-
if (!LINK_REGEXP.test(text)) {
|
|
157
|
-
return matches;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let startpos = 0;
|
|
161
|
-
let substr;
|
|
162
|
-
|
|
163
|
-
while (substr = text.substr(startpos)) {
|
|
164
|
-
const link = (substr.match(LINK_REGEXP) || [''])[0];
|
|
165
|
-
|
|
166
|
-
if (link) {
|
|
167
|
-
const index = substr.search(LINK_REGEXP);
|
|
168
|
-
const start = index >= 0 ? index + startpos : index;
|
|
169
|
-
const end = start + link.length;
|
|
170
|
-
matches.push({
|
|
171
|
-
index: start,
|
|
172
|
-
lastIndex: end,
|
|
173
|
-
raw: link,
|
|
174
|
-
url: link,
|
|
175
|
-
text: link,
|
|
176
|
-
schema: ''
|
|
177
|
-
});
|
|
178
|
-
startpos += end;
|
|
179
|
-
} else {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return matches;
|
|
185
|
-
};
|
|
129
|
+
}
|