@atlaskit/editor-core 172.0.5 → 172.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/cjs/create-editor/ReactEditorView.js +11 -2
- package/dist/cjs/create-editor/ReactEditorViewContext.js +15 -0
- package/dist/cjs/create-editor/create-plugins-list.js +2 -1
- package/dist/cjs/editor.js +7 -1
- package/dist/cjs/labs/next/mobile.js +5 -3
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/plugins/analytics/types/enums.js +1 -0
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +1 -1
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +8 -0
- package/dist/cjs/plugins/card/pm-plugins/doc.js +2 -26
- package/dist/cjs/plugins/card/toolbar.js +118 -86
- package/dist/cjs/plugins/code-block/nodeviews/code-block.js +9 -2
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +37 -1
- package/dist/cjs/plugins/code-block/toolbar.js +3 -1
- package/dist/cjs/plugins/code-block/ui/class-names.js +2 -0
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +4 -3
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -1
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +42 -2
- package/dist/cjs/plugins/hyperlink/Toolbar.js +43 -8
- package/dist/cjs/plugins/media/commands/helpers.js +1 -8
- package/dist/cjs/plugins/media/index.js +1 -1
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +0 -10
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/media.js +2 -3
- package/dist/cjs/plugins/media/picker-facade.js +1 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +3 -13
- package/dist/cjs/plugins/paste/handlers.js +9 -20
- package/dist/cjs/plugins/paste/md.js +8 -2
- package/dist/cjs/plugins/paste/newline-md-plugin.js +67 -0
- package/dist/cjs/plugins/paste/paragraph-md-plugin.js +72 -0
- package/dist/cjs/plugins/table/commands/hover.js +4 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/utils/decoration.js +53 -3
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -0
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +3 -2
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +78 -53
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +1 -1
- package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +7 -2
- package/dist/cjs/ui/Addon/ClickAreaMobile/index.js +8 -2
- package/dist/cjs/ui/Appearance/Comment/Comment.js +13 -13
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +8 -7
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/cjs/ui/Appearance/Mobile.js +4 -2
- package/dist/cjs/ui/AppearanceComponents/Mobile.js +5 -4
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/DropdownMenu/index.js +5 -5
- package/dist/cjs/ui/with-outer-listeners.js +105 -50
- package/dist/cjs/utils/deprecation-warnings.js +4 -0
- package/dist/cjs/utils/linking-utils.js +40 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +11 -2
- package/dist/es2019/create-editor/ReactEditorViewContext.js +3 -0
- package/dist/es2019/create-editor/create-plugins-list.js +2 -1
- package/dist/es2019/editor.js +7 -1
- package/dist/es2019/labs/next/mobile.js +5 -3
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/plugins/analytics/types/enums.js +1 -0
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +10 -0
- package/dist/es2019/plugins/card/pm-plugins/doc.js +1 -24
- package/dist/es2019/plugins/card/toolbar.js +114 -86
- package/dist/es2019/plugins/code-block/nodeviews/code-block.js +9 -2
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +40 -2
- package/dist/es2019/plugins/code-block/toolbar.js +2 -1
- package/dist/es2019/plugins/code-block/ui/class-names.js +2 -0
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +4 -3
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -2
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +37 -0
- package/dist/es2019/plugins/hyperlink/Toolbar.js +40 -9
- package/dist/es2019/plugins/media/commands/helpers.js +0 -2
- package/dist/es2019/plugins/media/index.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +0 -7
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/media.js +2 -3
- package/dist/es2019/plugins/media/picker-facade.js +1 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +3 -13
- package/dist/es2019/plugins/paste/handlers.js +7 -19
- package/dist/es2019/plugins/paste/md.js +6 -2
- package/dist/es2019/plugins/paste/newline-md-plugin.js +56 -0
- package/dist/es2019/plugins/paste/paragraph-md-plugin.js +61 -0
- package/dist/es2019/plugins/table/commands/hover.js +4 -4
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +39 -0
- package/dist/es2019/plugins/table/utils/decoration.js +60 -24
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -0
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +4 -3
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +78 -59
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +2 -2
- package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +6 -2
- package/dist/es2019/ui/Addon/ClickAreaMobile/index.js +7 -2
- package/dist/es2019/ui/Appearance/Comment/Comment.js +12 -6
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +7 -2
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/es2019/ui/Appearance/Mobile.js +4 -2
- package/dist/es2019/ui/AppearanceComponents/Mobile.js +5 -4
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/DropdownMenu/index.js +10 -6
- package/dist/es2019/ui/with-outer-listeners.js +83 -33
- package/dist/es2019/utils/deprecation-warnings.js +4 -0
- package/dist/es2019/utils/linking-utils.js +37 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +11 -2
- package/dist/esm/create-editor/ReactEditorViewContext.js +3 -0
- package/dist/esm/create-editor/create-plugins-list.js +2 -1
- package/dist/esm/editor.js +7 -1
- package/dist/esm/labs/next/mobile.js +5 -3
- package/dist/esm/messages.js +5 -0
- package/dist/esm/plugins/analytics/types/enums.js +1 -0
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +1 -1
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +9 -0
- package/dist/esm/plugins/card/pm-plugins/doc.js +1 -20
- package/dist/esm/plugins/card/toolbar.js +108 -83
- package/dist/esm/plugins/code-block/nodeviews/code-block.js +9 -2
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +37 -2
- package/dist/esm/plugins/code-block/toolbar.js +2 -1
- package/dist/esm/plugins/code-block/ui/class-names.js +2 -0
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +4 -3
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -2
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +41 -2
- package/dist/esm/plugins/hyperlink/Toolbar.js +43 -10
- package/dist/esm/plugins/media/commands/helpers.js +0 -4
- package/dist/esm/plugins/media/index.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +0 -8
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/media.js +2 -3
- package/dist/esm/plugins/media/picker-facade.js +1 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +3 -15
- package/dist/esm/plugins/paste/handlers.js +11 -22
- package/dist/esm/plugins/paste/md.js +6 -2
- package/dist/esm/plugins/paste/newline-md-plugin.js +58 -0
- package/dist/esm/plugins/paste/paragraph-md-plugin.js +63 -0
- package/dist/esm/plugins/table/commands/hover.js +4 -4
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/table/utils/decoration.js +50 -3
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -0
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +4 -3
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +77 -51
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +2 -2
- package/dist/esm/ui/Addon/ClickAreaBlock/index.js +7 -2
- package/dist/esm/ui/Addon/ClickAreaMobile/index.js +8 -2
- package/dist/esm/ui/Appearance/Comment/Comment.js +12 -12
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +7 -6
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/esm/ui/Appearance/Mobile.js +4 -2
- package/dist/esm/ui/AppearanceComponents/Mobile.js +5 -4
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/DropdownMenu/index.js +5 -5
- package/dist/esm/ui/with-outer-listeners.js +105 -51
- package/dist/esm/utils/deprecation-warnings.js +4 -0
- package/dist/esm/utils/linking-utils.js +37 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +2 -0
- package/dist/types/create-editor/ReactEditorViewContext.d.ts +8 -0
- package/dist/types/messages.d.ts +5 -0
- package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
- package/dist/types/plugins/analytics/types/events.d.ts +2 -2
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +3 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -2
- package/dist/types/plugins/card/toolbar.d.ts +1 -0
- package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -1
- package/dist/types/plugins/code-block/ui/class-names.d.ts +2 -0
- package/dist/types/plugins/hyperlink/types.d.ts +1 -0
- package/dist/types/plugins/media/commands/helpers.d.ts +0 -1
- package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +0 -1
- package/dist/types/plugins/media/nodeviews/mediaNodeView/media.d.ts +0 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +0 -2
- package/dist/types/plugins/media/pm-plugins/types.d.ts +0 -2
- package/dist/types/plugins/paste/newline-md-plugin.d.ts +2 -0
- package/dist/types/plugins/paste/paragraph-md-plugin.d.ts +2 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/dist/types/types/editor-appearance-component.d.ts +1 -0
- package/dist/types/types/feature-flags.d.ts +9 -0
- package/dist/types/ui/Addon/ClickAreaBlock/index.d.ts +1 -0
- package/dist/types/ui/Addon/ClickAreaMobile/index.d.ts +1 -0
- package/dist/types/ui/Appearance/FullPage/FullPage.d.ts +1 -0
- package/dist/types/ui/Appearance/Mobile.d.ts +1 -1
- package/dist/types/ui/AppearanceComponents/Mobile.d.ts +2 -1
- package/dist/types/ui/Dropdown/index.d.ts +1 -1
- package/dist/types/ui/with-outer-listeners.d.ts +2 -1
- package/dist/types/utils/linking-utils.d.ts +1 -0
- package/package.json +30 -32
- package/dist/cjs/plugins/type-ahead/ui/DynamicHeightListItem.js +0 -77
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +0 -118
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-resize-observer.js +0 -70
- package/dist/es2019/plugins/type-ahead/ui/DynamicHeightListItem.js +0 -51
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +0 -97
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-resize-observer.js +0 -53
- package/dist/esm/plugins/type-ahead/ui/DynamicHeightListItem.js +0 -51
- package/dist/esm/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +0 -101
- package/dist/esm/plugins/type-ahead/ui/hooks/use-resize-observer.js +0 -48
- package/dist/types/plugins/type-ahead/ui/DynamicHeightListItem.d.ts +0 -21
- package/dist/types/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.d.ts +0 -25
- package/dist/types/plugins/type-ahead/ui/hooks/use-resize-observer.d.ts +0 -8
|
@@ -3,6 +3,7 @@ import { NodeSelection } from 'prosemirror-state';
|
|
|
3
3
|
import { removeSelectedNode, findDomRefAtPos } from 'prosemirror-utils';
|
|
4
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
5
5
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
6
|
+
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
6
7
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
7
8
|
import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, addAnalytics } from '../analytics';
|
|
8
9
|
import { linkToolbarMessages, linkMessages } from '../../messages';
|
|
@@ -17,9 +18,10 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
17
18
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
18
19
|
import { messages } from './messages';
|
|
19
20
|
import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
|
|
20
|
-
import { buildVisitedLinkPayload } from '../../utils/linking-utils';
|
|
21
|
+
import { buildOpenedSettingsPayload, buildVisitedLinkPayload } from '../../utils/linking-utils';
|
|
21
22
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
|
|
22
23
|
import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
|
|
24
|
+
import { getFeatureFlags } from '../feature-flags-context';
|
|
23
25
|
export const removeCard = (state, dispatch) => {
|
|
24
26
|
if (!(state.selection instanceof NodeSelection)) {
|
|
25
27
|
return false;
|
|
@@ -64,6 +66,73 @@ export const visitCardLink = (state, dispatch) => {
|
|
|
64
66
|
|
|
65
67
|
return true;
|
|
66
68
|
};
|
|
69
|
+
export const openLinkSettings = (state, dispatch) => {
|
|
70
|
+
if (!(state.selection instanceof NodeSelection)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
window.open('https://id.atlassian.com/manage-profile/link-preferences');
|
|
75
|
+
|
|
76
|
+
if (dispatch) {
|
|
77
|
+
const {
|
|
78
|
+
type
|
|
79
|
+
} = state.selection.node;
|
|
80
|
+
dispatch(addAnalytics(state, state.tr, buildOpenedSettingsPayload(type.name)));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
export const floatingToolbar = (cardOptions, platform, linkPickerOptions) => {
|
|
86
|
+
return (state, intl, providerFactory) => {
|
|
87
|
+
const {
|
|
88
|
+
inlineCard,
|
|
89
|
+
blockCard,
|
|
90
|
+
embedCard
|
|
91
|
+
} = state.schema.nodes;
|
|
92
|
+
const nodeType = [inlineCard, blockCard, embedCard];
|
|
93
|
+
const pluginState = pluginKey.getState(state);
|
|
94
|
+
|
|
95
|
+
if (!(state.selection instanceof NodeSelection)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const selectedNode = state.selection.node;
|
|
100
|
+
|
|
101
|
+
if (!selectedNode) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const isEmbedCard = appearanceForNodeType(selectedNode.type) === 'embed';
|
|
106
|
+
/* add an offset to embeds due to extra padding */
|
|
107
|
+
|
|
108
|
+
const toolbarOffset = isEmbedCard ? {
|
|
109
|
+
offset: [0, 24]
|
|
110
|
+
} : {}; // Applies padding override for when link picker is currently displayed
|
|
111
|
+
|
|
112
|
+
const className = pluginState.showLinkingToolbar ? FLOATING_TOOLBAR_LINKPICKER_CLASSNAME : undefined;
|
|
113
|
+
return {
|
|
114
|
+
title: intl.formatMessage(messages.card),
|
|
115
|
+
className,
|
|
116
|
+
nodeType,
|
|
117
|
+
...toolbarOffset,
|
|
118
|
+
getDomRef: view => {
|
|
119
|
+
const element = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
120
|
+
|
|
121
|
+
if (!element) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (isEmbedCard) {
|
|
126
|
+
return element.querySelector(`.${richMediaClassName}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return element;
|
|
130
|
+
},
|
|
131
|
+
items: generateToolbarItems(state, intl, providerFactory, cardOptions, platform, linkPickerOptions),
|
|
132
|
+
...(pluginState.showLinkingToolbar ? editLinkToolbarConfig : {})
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
67
136
|
|
|
68
137
|
const unlinkCard = (node, state) => {
|
|
69
138
|
const displayInfo = displayInfoForCard(node, findCardInfo(state));
|
|
@@ -80,42 +149,6 @@ const buildAlignmentOptions = (state, intl) => {
|
|
|
80
149
|
return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, true, true);
|
|
81
150
|
};
|
|
82
151
|
|
|
83
|
-
const generateDeleteButton = (node, state, intl) => {
|
|
84
|
-
const {
|
|
85
|
-
inlineCard
|
|
86
|
-
} = state.schema.nodes;
|
|
87
|
-
const removeButton = {
|
|
88
|
-
id: 'editor.link.delete',
|
|
89
|
-
type: 'button',
|
|
90
|
-
appearance: 'danger',
|
|
91
|
-
icon: RemoveIcon,
|
|
92
|
-
onMouseEnter: hoverDecoration(node.type, true),
|
|
93
|
-
onMouseLeave: hoverDecoration(node.type, false),
|
|
94
|
-
onFocus: hoverDecoration(node.type, true),
|
|
95
|
-
onBlur: hoverDecoration(node.type, false),
|
|
96
|
-
title: intl.formatMessage(commonMessages.remove),
|
|
97
|
-
onClick: removeCard
|
|
98
|
-
};
|
|
99
|
-
const copyButton = [...(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, node.type), {
|
|
100
|
-
type: 'separator'
|
|
101
|
-
}] : [])];
|
|
102
|
-
|
|
103
|
-
if (node.type === inlineCard) {
|
|
104
|
-
const unlinkButtonWithSeparator = [{
|
|
105
|
-
id: 'editor.link.unlink',
|
|
106
|
-
type: 'button',
|
|
107
|
-
title: intl.formatMessage(linkToolbarMessages.unlink),
|
|
108
|
-
icon: UnlinkIcon,
|
|
109
|
-
onClick: unlinkCard(node, state)
|
|
110
|
-
}, {
|
|
111
|
-
type: 'separator'
|
|
112
|
-
}];
|
|
113
|
-
return [...unlinkButtonWithSeparator, ...copyButton, removeButton];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return [...copyButton, removeButton];
|
|
117
|
-
};
|
|
118
|
-
|
|
119
152
|
const generateToolbarItems = (state, intl, providerFactory, cardOptions, platform, linkPicker) => node => {
|
|
120
153
|
const {
|
|
121
154
|
url
|
|
@@ -145,6 +178,9 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
|
|
|
145
178
|
node
|
|
146
179
|
})];
|
|
147
180
|
} else {
|
|
181
|
+
const {
|
|
182
|
+
inlineCard
|
|
183
|
+
} = state.schema.nodes;
|
|
148
184
|
const toolbarItems = [{
|
|
149
185
|
id: 'editor.link.edit',
|
|
150
186
|
type: 'button',
|
|
@@ -166,7 +202,18 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
|
|
|
166
202
|
onClick: visitCardLink
|
|
167
203
|
}, {
|
|
168
204
|
type: 'separator'
|
|
169
|
-
}, ...
|
|
205
|
+
}, ...getUnlinkButtonGroup(state, intl, node, inlineCard), ...getCopyButtonGroup(state, intl, node), ...getSettingsButtonGroup(state, intl), {
|
|
206
|
+
id: 'editor.link.delete',
|
|
207
|
+
type: 'button',
|
|
208
|
+
appearance: 'danger',
|
|
209
|
+
icon: RemoveIcon,
|
|
210
|
+
onMouseEnter: hoverDecoration(node.type, true),
|
|
211
|
+
onMouseLeave: hoverDecoration(node.type, false),
|
|
212
|
+
onFocus: hoverDecoration(node.type, true),
|
|
213
|
+
onBlur: hoverDecoration(node.type, false),
|
|
214
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
215
|
+
onClick: removeCard
|
|
216
|
+
}];
|
|
170
217
|
|
|
171
218
|
if (currentAppearance === 'embed') {
|
|
172
219
|
const alignmentOptions = buildAlignmentOptions(state, intl);
|
|
@@ -208,54 +255,35 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
|
|
|
208
255
|
}
|
|
209
256
|
};
|
|
210
257
|
|
|
211
|
-
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const selectedNode = state.selection.node;
|
|
226
|
-
|
|
227
|
-
if (!selectedNode) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const isEmbedCard = appearanceForNodeType(selectedNode.type) === 'embed';
|
|
232
|
-
/* add an offset to embeds due to extra padding */
|
|
233
|
-
|
|
234
|
-
const toolbarOffset = isEmbedCard ? {
|
|
235
|
-
offset: [0, 24]
|
|
236
|
-
} : {}; // Applies padding override for when link picker is currently displayed
|
|
237
|
-
|
|
238
|
-
const className = pluginState.showLinkingToolbar ? FLOATING_TOOLBAR_LINKPICKER_CLASSNAME : undefined;
|
|
239
|
-
return {
|
|
240
|
-
title: intl.formatMessage(messages.card),
|
|
241
|
-
className,
|
|
242
|
-
nodeType,
|
|
243
|
-
...toolbarOffset,
|
|
244
|
-
getDomRef: view => {
|
|
245
|
-
const element = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
246
|
-
|
|
247
|
-
if (!element) {
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
258
|
+
const getUnlinkButtonGroup = (state, intl, node, inlineCard) => {
|
|
259
|
+
return node.type === inlineCard ? [{
|
|
260
|
+
id: 'editor.link.unlink',
|
|
261
|
+
type: 'button',
|
|
262
|
+
title: intl.formatMessage(linkToolbarMessages.unlink),
|
|
263
|
+
icon: UnlinkIcon,
|
|
264
|
+
onClick: unlinkCard(node, state)
|
|
265
|
+
}, {
|
|
266
|
+
type: 'separator'
|
|
267
|
+
}] : [];
|
|
268
|
+
};
|
|
250
269
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
270
|
+
const getSettingsButtonGroup = (state, intl) => {
|
|
271
|
+
const {
|
|
272
|
+
floatingToolbarLinkSettingsButton
|
|
273
|
+
} = getFeatureFlags(state);
|
|
274
|
+
return floatingToolbarLinkSettingsButton === 'true' ? [{
|
|
275
|
+
id: 'editor.link.settings',
|
|
276
|
+
type: 'button',
|
|
277
|
+
icon: CogIcon,
|
|
278
|
+
title: intl.formatMessage(linkToolbarMessages.settingsLink),
|
|
279
|
+
onClick: openLinkSettings
|
|
280
|
+
}, {
|
|
281
|
+
type: 'separator'
|
|
282
|
+
}] : [];
|
|
283
|
+
};
|
|
254
284
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
};
|
|
260
|
-
};
|
|
285
|
+
const getCopyButtonGroup = (state, intl, node) => {
|
|
286
|
+
return state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, node.type), {
|
|
287
|
+
type: 'separator'
|
|
288
|
+
}] : [];
|
|
261
289
|
};
|
|
@@ -10,6 +10,9 @@ const MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
|
10
10
|
const toDOM = node => ['div', {
|
|
11
11
|
class: 'code-block'
|
|
12
12
|
}, ['div', {
|
|
13
|
+
class: codeBlockClassNames.start,
|
|
14
|
+
contenteditable: 'false'
|
|
15
|
+
}], ['div', {
|
|
13
16
|
class: codeBlockClassNames.gutter,
|
|
14
17
|
contenteditable: 'false'
|
|
15
18
|
}], ['div', {
|
|
@@ -17,8 +20,12 @@ const toDOM = node => ['div', {
|
|
|
17
20
|
}, ['code', {
|
|
18
21
|
'data-language': node.attrs.language || '',
|
|
19
22
|
spellcheck: 'false',
|
|
20
|
-
contenteditable: 'true'
|
|
21
|
-
|
|
23
|
+
contenteditable: 'true',
|
|
24
|
+
'data-testid': 'code-block--code'
|
|
25
|
+
}, 0]], ['div', {
|
|
26
|
+
class: codeBlockClassNames.end,
|
|
27
|
+
contenteditable: 'false'
|
|
28
|
+
}]];
|
|
22
29
|
|
|
23
30
|
export class CodeBlockView {
|
|
24
31
|
constructor(_node, view, getPos) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
3
3
|
import { keydownHandler } from 'prosemirror-keymap';
|
|
4
4
|
import { setTextSelection } from 'prosemirror-utils';
|
|
5
5
|
import { getCursor } from '../../../utils';
|
|
@@ -9,15 +9,53 @@ import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bra
|
|
|
9
9
|
import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
|
|
10
10
|
import { getEndOfCurrentLine, getStartOfCurrentLine, isCursorInsideCodeBlock, isSelectionEntirelyInsideCodeBlock, getLineInfo } from '../ide-ux/line-handling';
|
|
11
11
|
import { insertIndent, outdent, indent, insertNewlineWithIndent } from '../ide-ux/commands';
|
|
12
|
+
const codeBlockIDEKeyBindingsKey = new PluginKey('codeBlockIDEKeyBindings');
|
|
12
13
|
export default new SafePlugin({
|
|
14
|
+
key: codeBlockIDEKeyBindingsKey,
|
|
15
|
+
state: {
|
|
16
|
+
init: () => ({
|
|
17
|
+
isComposing: false
|
|
18
|
+
}),
|
|
19
|
+
apply: (tr, value) => {
|
|
20
|
+
const isComposing = tr.getMeta(codeBlockIDEKeyBindingsKey);
|
|
21
|
+
|
|
22
|
+
if (typeof isComposing === 'undefined') {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
isComposing
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
},
|
|
13
31
|
props: {
|
|
32
|
+
handleDOMEvents: {
|
|
33
|
+
compositionstart: (view, event) => {
|
|
34
|
+
const {
|
|
35
|
+
tr
|
|
36
|
+
} = view.state;
|
|
37
|
+
tr.setMeta(codeBlockIDEKeyBindingsKey, true);
|
|
38
|
+
view.dispatch(tr);
|
|
39
|
+
return false;
|
|
40
|
+
},
|
|
41
|
+
compositionend: (view, event) => {
|
|
42
|
+
const {
|
|
43
|
+
tr
|
|
44
|
+
} = view.state;
|
|
45
|
+
tr.setMeta(codeBlockIDEKeyBindingsKey, false);
|
|
46
|
+
view.dispatch(tr);
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
14
51
|
handleTextInput(view, from, to, text) {
|
|
15
52
|
const {
|
|
16
53
|
state,
|
|
17
54
|
dispatch
|
|
18
55
|
} = view;
|
|
56
|
+
const isComposing = codeBlockIDEKeyBindingsKey.getState(state).isComposing;
|
|
19
57
|
|
|
20
|
-
if (isCursorInsideCodeBlock(state)) {
|
|
58
|
+
if (isCursorInsideCodeBlock(state) && !isComposing) {
|
|
21
59
|
const beforeText = getStartOfCurrentLine(state).text;
|
|
22
60
|
const afterText = getEndOfCurrentLine(state).text; // If text is a closing bracket/quote and we've already inserted it, move the selection after
|
|
23
61
|
|
|
@@ -4,6 +4,7 @@ import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
|
4
4
|
import { findDomRefAtPos } from 'prosemirror-utils';
|
|
5
5
|
import { removeCodeBlock, changeLanguage, copyContentToClipboard, resetCopiedState } from './actions';
|
|
6
6
|
import commonMessages from '../../messages';
|
|
7
|
+
import { codeBlockCopyButtonMessages } from '@atlaskit/editor-common/messages';
|
|
7
8
|
import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
8
9
|
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
9
10
|
import { pluginKey } from './plugin-key';
|
|
@@ -64,7 +65,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false) => (state, {
|
|
|
64
65
|
// note: copyContentToClipboard contains logic that also removes the
|
|
65
66
|
// visual feedback for the copy button
|
|
66
67
|
onClick: copyContentToClipboard,
|
|
67
|
-
title: formatMessage(codeBlockState.contentCopied ?
|
|
68
|
+
title: formatMessage(codeBlockState.contentCopied ? codeBlockCopyButtonMessages.copiedCodeToClipboard : codeBlockCopyButtonMessages.copyCodeToClipboard),
|
|
68
69
|
onMouseEnter: provideVisualFeedbackForCopyButton,
|
|
69
70
|
// note: resetCopiedState contains logic that also removes the
|
|
70
71
|
// visual feedback for the copy button
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
2
2
|
export const codeBlockClassNames = {
|
|
3
|
+
start: CodeBlockSharedCssClassName.CODEBLOCK_START,
|
|
4
|
+
end: CodeBlockSharedCssClassName.CODEBLOCK_END,
|
|
3
5
|
gutter: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
|
|
4
6
|
content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
|
|
5
7
|
};
|
|
@@ -26,7 +26,7 @@ function getSpellCheck(featureFlags) {
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
export function createFeatureFlagsFromProps(props) {
|
|
29
|
-
var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$featureFlags9, _props$featureFlags10, _props$
|
|
29
|
+
var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$allowTables5, _props$featureFlags9, _props$featureFlags10, _props$allowTables6, _props$allowExtension, _props$featureFlags11, _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, _props$featureFlags28, _props$featureFlags29, _props$featureFlags30, _props$collabEdit, _props$collabEdit2, _props$featureFlags31, _props$featureFlags32, _props$featureFlags33, _props$featureFlags34, _props$featureFlags35, _props$featureFlags36, _props$featureFlags37, _props$featureFlags38, _props$featureFlags39;
|
|
30
30
|
|
|
31
31
|
const normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
|
|
32
32
|
return { ...normalizedFeatureFlags,
|
|
@@ -45,8 +45,8 @@ export function createFeatureFlagsFromProps(props) {
|
|
|
45
45
|
stickyHeadersOptimization: typeof ((_props$featureFlags = props.featureFlags) === null || _props$featureFlags === void 0 ? void 0 : _props$featureFlags.stickyHeadersOptimization) === 'boolean' ? !!((_props$featureFlags2 = props.featureFlags) !== null && _props$featureFlags2 !== void 0 && _props$featureFlags2.stickyHeadersOptimization) : typeof props.allowTables === 'object' && !!((_props$allowTables = props.allowTables) !== null && _props$allowTables !== void 0 && _props$allowTables.stickyHeadersOptimization),
|
|
46
46
|
initialRenderOptimization: typeof ((_props$featureFlags3 = props.featureFlags) === null || _props$featureFlags3 === void 0 ? void 0 : _props$featureFlags3.initialRenderOptimization) === 'boolean' ? !!((_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.initialRenderOptimization) : typeof props.allowTables === 'object' && !!((_props$allowTables2 = props.allowTables) !== null && _props$allowTables2 !== void 0 && _props$allowTables2.initialRenderOptimization),
|
|
47
47
|
mouseMoveOptimization: typeof ((_props$featureFlags5 = props.featureFlags) === null || _props$featureFlags5 === void 0 ? void 0 : _props$featureFlags5.mouseMoveOptimization) === 'boolean' ? !!((_props$featureFlags6 = props.featureFlags) !== null && _props$featureFlags6 !== void 0 && _props$featureFlags6.mouseMoveOptimization) : typeof props.allowTables === 'object' && !!((_props$allowTables3 = props.allowTables) !== null && _props$allowTables3 !== void 0 && _props$allowTables3.mouseMoveOptimization),
|
|
48
|
-
tableRenderOptimization: typeof ((_props$featureFlags7 = props.featureFlags) === null || _props$featureFlags7 === void 0 ? void 0 : _props$featureFlags7.tableRenderOptimization) === 'boolean' ? !!((_props$featureFlags8 = props.featureFlags) !== null && _props$featureFlags8 !== void 0 && _props$featureFlags8.tableRenderOptimization) : typeof props.allowTables === 'object' &&
|
|
49
|
-
tableOverflowShadowsOptimization: typeof ((_props$featureFlags9 = props.featureFlags) === null || _props$featureFlags9 === void 0 ? void 0 : _props$featureFlags9.tableOverflowShadowsOptimization) === 'boolean' ? !!((_props$featureFlags10 = props.featureFlags) !== null && _props$featureFlags10 !== void 0 && _props$featureFlags10.tableOverflowShadowsOptimization) : typeof props.allowTables === 'object' && !!((_props$
|
|
48
|
+
tableRenderOptimization: typeof ((_props$featureFlags7 = props.featureFlags) === null || _props$featureFlags7 === void 0 ? void 0 : _props$featureFlags7.tableRenderOptimization) === 'boolean' ? !!((_props$featureFlags8 = props.featureFlags) !== null && _props$featureFlags8 !== void 0 && _props$featureFlags8.tableRenderOptimization) : typeof props.allowTables === 'object' && typeof ((_props$allowTables4 = props.allowTables) === null || _props$allowTables4 === void 0 ? void 0 : _props$allowTables4.tableRenderOptimization) === 'boolean' ? (_props$allowTables5 = props.allowTables) === null || _props$allowTables5 === void 0 ? void 0 : _props$allowTables5.tableRenderOptimization : true,
|
|
49
|
+
tableOverflowShadowsOptimization: typeof ((_props$featureFlags9 = props.featureFlags) === null || _props$featureFlags9 === void 0 ? void 0 : _props$featureFlags9.tableOverflowShadowsOptimization) === 'boolean' ? !!((_props$featureFlags10 = props.featureFlags) !== null && _props$featureFlags10 !== void 0 && _props$featureFlags10.tableOverflowShadowsOptimization) : typeof props.allowTables === 'object' && !!((_props$allowTables6 = props.allowTables) !== null && _props$allowTables6 !== void 0 && _props$allowTables6.tableOverflowShadowsOptimization),
|
|
50
50
|
extendFloatingToolbar: Boolean(typeof props.allowExtension === 'object' && ((_props$allowExtension = props.allowExtension) === null || _props$allowExtension === void 0 ? void 0 : _props$allowExtension.allowExtendFloatingToolbars)),
|
|
51
51
|
useUnpredictableInputRule: Boolean(typeof ((_props$featureFlags11 = props.featureFlags) === null || _props$featureFlags11 === void 0 ? void 0 : _props$featureFlags11.useUnpredictableInputRule) === 'boolean' ? !!((_props$featureFlags12 = props.featureFlags) !== null && _props$featureFlags12 !== void 0 && _props$featureFlags12.useUnpredictableInputRule) : props.UNSAFE_allowUndoRedoButtons ? false : true),
|
|
52
52
|
showAvatarGroupAsPlugin: Boolean(typeof ((_props$featureFlags13 = props.featureFlags) === null || _props$featureFlags13 === void 0 ? void 0 : _props$featureFlags13.showAvatarGroupAsPlugin) === 'boolean' ? !!((_props$featureFlags14 = props.featureFlags) !== null && _props$featureFlags14 !== void 0 && _props$featureFlags14.showAvatarGroupAsPlugin) : false),
|
|
@@ -64,6 +64,7 @@ export function createFeatureFlagsFromProps(props) {
|
|
|
64
64
|
showHoverPreview: Boolean(typeof ((_props$featureFlags33 = props.featureFlags) === null || _props$featureFlags33 === void 0 ? void 0 : _props$featureFlags33.showHoverPreview) === 'boolean' ? !!((_props$featureFlags34 = props.featureFlags) !== null && _props$featureFlags34 !== void 0 && _props$featureFlags34.showHoverPreview) : false),
|
|
65
65
|
indentationButtonsInTheToolbar: Boolean(typeof normalizedFeatureFlags.indentationButtonsInTheToolbar === 'boolean' && !!normalizedFeatureFlags.indentationButtonsInTheToolbar || (typeof ((_props$featureFlags35 = props.featureFlags) === null || _props$featureFlags35 === void 0 ? void 0 : _props$featureFlags35.indentationButtonsInTheToolbar) === 'boolean' ? !!((_props$featureFlags36 = props.featureFlags) !== null && _props$featureFlags36 !== void 0 && _props$featureFlags36.indentationButtonsInTheToolbar) : false)),
|
|
66
66
|
floatingToolbarCopyButton: Boolean(typeof normalizedFeatureFlags.floatingToolbarCopyButton === 'boolean' && !!normalizedFeatureFlags.floatingToolbarCopyButton || (typeof ((_props$featureFlags37 = props.featureFlags) === null || _props$featureFlags37 === void 0 ? void 0 : _props$featureFlags37.floatingToolbarCopyButton) === 'boolean' ? !!((_props$featureFlags38 = props.featureFlags) !== null && _props$featureFlags38 !== void 0 && _props$featureFlags38.floatingToolbarCopyButton) : false)),
|
|
67
|
+
floatingToolbarLinkSettingsButton: typeof ((_props$featureFlags39 = props.featureFlags) === null || _props$featureFlags39 === void 0 ? void 0 : _props$featureFlags39['floating-toolbar-link-settings-button']) === 'string' ? props.featureFlags['floating-toolbar-link-settings-button'] || undefined : undefined,
|
|
67
68
|
disableSpellcheckByBrowser: getSpellCheck(props.featureFlags)
|
|
68
69
|
};
|
|
69
70
|
}
|
|
@@ -3,10 +3,11 @@ import { css, jsx } from '@emotion/react';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Button from '@atlaskit/button';
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
-
import { Popup
|
|
6
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { EmojiPicker } from '@atlaskit/emoji';
|
|
8
8
|
import Tooltip from '@atlaskit/tooltip';
|
|
9
|
-
import EditorEmojiAddIcon from './EditorEmojiAddIcon';
|
|
9
|
+
import EditorEmojiAddIcon from './EditorEmojiAddIcon';
|
|
10
|
+
import withOuterListeners from '../../../ui/with-outer-listeners'; // helps adjusts position of popup
|
|
10
11
|
|
|
11
12
|
const emojiPickerButtonWrapper = css`
|
|
12
13
|
position: relative;
|
|
@@ -21,6 +21,7 @@ import Announcer from '../../../utils/announcer/announcer';
|
|
|
21
21
|
import { injectIntl } from 'react-intl-next';
|
|
22
22
|
import messages from './messages';
|
|
23
23
|
import { token } from '@atlaskit/tokens';
|
|
24
|
+
import { decorationStateKey, ACTIONS } from '../../base/pm-plugins/decoration';
|
|
24
25
|
const akGridSize = gridSize();
|
|
25
26
|
|
|
26
27
|
const toolbarContainer = theme => css`
|
|
@@ -107,6 +108,42 @@ export const areSameItems = (leftArr, rightArr) => {
|
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
class Toolbar extends Component {
|
|
111
|
+
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
112
|
+
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
113
|
+
resetStyling({
|
|
114
|
+
table
|
|
115
|
+
}) {
|
|
116
|
+
if (this.props.editorView) {
|
|
117
|
+
const {
|
|
118
|
+
state,
|
|
119
|
+
dispatch
|
|
120
|
+
} = this.props.editorView; // tables use their own decorations
|
|
121
|
+
// TODO fix for tables https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-617
|
|
122
|
+
|
|
123
|
+
if (table) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
dispatch(state.tr.setMeta(decorationStateKey, {
|
|
128
|
+
action: ACTIONS.DECORATION_REMOVE
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
componentDidUpdate(prevProps) {
|
|
134
|
+
if (this.props.node !== prevProps.node) {
|
|
135
|
+
this.resetStyling({
|
|
136
|
+
table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
componentWillUnmount() {
|
|
142
|
+
this.resetStyling({
|
|
143
|
+
table: this.props.node.type.name === 'table'
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
110
147
|
render() {
|
|
111
148
|
const {
|
|
112
149
|
items,
|
|
@@ -3,6 +3,7 @@ import { stateKey } from './pm-plugins/main';
|
|
|
3
3
|
import { removeLink, editInsertedLink, updateLink, insertLinkWithAnalytics } from './commands';
|
|
4
4
|
import HyperlinkAddToolbar from './ui/HyperlinkAddToolbar';
|
|
5
5
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
6
|
+
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
6
7
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
7
8
|
import { normalizeUrl } from './utils';
|
|
8
9
|
import { linkToolbarMessages as linkToolbarCommonMessages, linkMessages } from '../../messages';
|
|
@@ -10,19 +11,28 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
10
11
|
import { RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '../../ui/LinkSearch/ToolbarComponents';
|
|
11
12
|
import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
|
|
12
13
|
import { addAnalytics, ACTION_SUBJECT_ID } from '../analytics';
|
|
13
|
-
import { buildVisitedLinkPayload } from '../../utils/linking-utils';
|
|
14
|
+
import { buildVisitedLinkPayload, buildOpenedSettingsPayload } from '../../utils/linking-utils';
|
|
14
15
|
import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
|
|
15
|
-
|
|
16
|
+
import { getFeatureFlags } from '../feature-flags-context';
|
|
16
17
|
/* type guard for edit links */
|
|
18
|
+
|
|
17
19
|
function isEditLink(linkMark) {
|
|
18
20
|
return linkMark.pos !== undefined;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const
|
|
23
|
+
const dispatchAnalytics = (dispatch, state, analyticsBuilder) => {
|
|
22
24
|
if (dispatch) {
|
|
23
|
-
dispatch(addAnalytics(state, state.tr,
|
|
25
|
+
dispatch(addAnalytics(state, state.tr, analyticsBuilder(ACTION_SUBJECT_ID.HYPERLINK)));
|
|
24
26
|
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const visitHyperlink = () => (state, dispatch) => {
|
|
30
|
+
dispatchAnalytics(dispatch, state, buildVisitedLinkPayload);
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
25
33
|
|
|
34
|
+
const openLinkSettings = () => (state, dispatch) => {
|
|
35
|
+
dispatchAnalytics(dispatch, state, buildOpenedSettingsPayload);
|
|
26
36
|
return true;
|
|
27
37
|
};
|
|
28
38
|
|
|
@@ -42,6 +52,29 @@ function getLinkText(activeLinkMark, state) {
|
|
|
42
52
|
return activeLinkMark.node.text;
|
|
43
53
|
}
|
|
44
54
|
|
|
55
|
+
const getCopyButtonGroup = (state, intl, nodeType) => {
|
|
56
|
+
return state && showCopyButton(state) ? [{
|
|
57
|
+
type: 'separator'
|
|
58
|
+
}, getCopyButtonConfig(state, intl.formatMessage, nodeType)] : [];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getSettingsButtonGroup = (state, intl) => {
|
|
62
|
+
const {
|
|
63
|
+
floatingToolbarLinkSettingsButton
|
|
64
|
+
} = getFeatureFlags(state);
|
|
65
|
+
return floatingToolbarLinkSettingsButton === 'true' ? [{
|
|
66
|
+
type: 'separator'
|
|
67
|
+
}, {
|
|
68
|
+
id: 'editor.link.settings',
|
|
69
|
+
type: 'button',
|
|
70
|
+
icon: CogIcon,
|
|
71
|
+
title: intl.formatMessage(linkToolbarCommonMessages.settingsLink),
|
|
72
|
+
onClick: openLinkSettings(),
|
|
73
|
+
href: 'https://id.atlassian.com/manage-profile/link-preferences',
|
|
74
|
+
target: '_blank'
|
|
75
|
+
}] : [];
|
|
76
|
+
};
|
|
77
|
+
|
|
45
78
|
export const getToolbarConfig = options => (state, intl, providerFactory) => {
|
|
46
79
|
const {
|
|
47
80
|
formatMessage
|
|
@@ -97,8 +130,8 @@ export const getToolbarConfig = options => (state, intl, providerFactory) => {
|
|
|
97
130
|
editorView: editorView,
|
|
98
131
|
editorState: state,
|
|
99
132
|
cardOptions: options === null || options === void 0 ? void 0 : options.cardOptions,
|
|
100
|
-
providerFactory: providerFactory
|
|
101
|
-
|
|
133
|
+
providerFactory: providerFactory,
|
|
134
|
+
platform: options === null || options === void 0 ? void 0 : options.platform
|
|
102
135
|
});
|
|
103
136
|
}
|
|
104
137
|
}, {
|
|
@@ -134,9 +167,7 @@ export const getToolbarConfig = options => (state, intl, providerFactory) => {
|
|
|
134
167
|
title: labelUnlink,
|
|
135
168
|
icon: UnlinkIcon,
|
|
136
169
|
tabIndex: null
|
|
137
|
-
}, ...(state
|
|
138
|
-
type: 'separator'
|
|
139
|
-
}, getCopyButtonConfig(state, intl.formatMessage, hyperLinkToolbar.nodeType)] : [])]
|
|
170
|
+
}, ...getCopyButtonGroup(state, intl, hyperLinkToolbar.nodeType), ...getSettingsButtonGroup(state, intl)]
|
|
140
171
|
};
|
|
141
172
|
}
|
|
142
173
|
|
|
@@ -54,8 +54,6 @@ export const findMediaNode = (mediaPluginState, id, isMediaSingle) => {
|
|
|
54
54
|
|
|
55
55
|
return mediaNodeWithPos;
|
|
56
56
|
};
|
|
57
|
-
export const isMobileUploadCompleted = (mediaPluginState, mediaId) => !!mediaPluginState.mediaOptions && // This flag tells us that it's a 'mobile' env.
|
|
58
|
-
!!mediaPluginState.mediaOptions.allowMarkingUploadsAsIncomplete && typeof mediaPluginState.mobileUploadComplete[mediaId] === 'boolean' ? mediaPluginState.mobileUploadComplete[mediaId] : undefined;
|
|
59
57
|
export const isMediaNode = (pos, state) => {
|
|
60
58
|
const node = state.doc.nodeAt(pos);
|
|
61
59
|
return node && ['media', 'mediaInline'].includes(node.type.name);
|
|
@@ -178,7 +178,7 @@ const mediaPlugin = options => ({
|
|
|
178
178
|
title: formatMessage(messages.filesAndImages),
|
|
179
179
|
description: formatMessage(messages.filesAndImagesDescription),
|
|
180
180
|
priority: 400,
|
|
181
|
-
keywords: ['attachment', 'gif', 'media', 'picture'],
|
|
181
|
+
keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
|
|
182
182
|
icon: () => /*#__PURE__*/React.createElement(IconImages, null),
|
|
183
183
|
|
|
184
184
|
action(insert, state) {
|
|
@@ -7,8 +7,6 @@ import React from 'react';
|
|
|
7
7
|
import { SelectionBasedNodeView } from '../../../../nodeviews';
|
|
8
8
|
import WithPluginState from '../../../../ui/WithPluginState';
|
|
9
9
|
import { pluginKey as widthPluginKey } from '../../../width';
|
|
10
|
-
import { isMobileUploadCompleted } from '../../commands/helpers';
|
|
11
|
-
import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
|
|
12
10
|
import MediaNode from './media';
|
|
13
11
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
14
12
|
import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
|
|
@@ -71,7 +69,6 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
71
69
|
url: url,
|
|
72
70
|
mediaProvider: mediaProvider,
|
|
73
71
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
74
|
-
uploadComplete: this.uploadComplete(),
|
|
75
72
|
mediaOptions: mediaOptions
|
|
76
73
|
});
|
|
77
74
|
};
|
|
@@ -136,10 +133,6 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
136
133
|
return isMediaBlobUrlFromAttrs(attrs);
|
|
137
134
|
}
|
|
138
135
|
|
|
139
|
-
uploadComplete() {
|
|
140
|
-
return isMobileUploadCompleted(mediaStateKey.getState(this.view.state), this.node.attrs.id);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
136
|
render() {
|
|
144
137
|
const {
|
|
145
138
|
providerFactory
|
|
@@ -76,7 +76,7 @@ export class MediaNode extends Component {
|
|
|
76
76
|
shouldComponentUpdate(nextProps, nextState) {
|
|
77
77
|
const hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
|
|
78
78
|
|
|
79
|
-
if (this.props.selected !== nextProps.selected || this.props.
|
|
79
|
+
if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.mediaProvider !== nextProps.mediaProvider || hasNewViewMediaClientConfig) {
|
|
80
80
|
return true;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -115,7 +115,6 @@ export class MediaNode extends Component {
|
|
|
115
115
|
const {
|
|
116
116
|
node,
|
|
117
117
|
selected,
|
|
118
|
-
uploadComplete,
|
|
119
118
|
originalDimensions,
|
|
120
119
|
isLoading,
|
|
121
120
|
maxDimensions,
|
|
@@ -133,7 +132,7 @@ export class MediaNode extends Component {
|
|
|
133
132
|
alt
|
|
134
133
|
} = node.attrs;
|
|
135
134
|
|
|
136
|
-
if (isLoading || type !== 'external' &&
|
|
135
|
+
if (isLoading || type !== 'external' && !viewMediaClientConfig) {
|
|
137
136
|
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
138
137
|
dimensions: originalDimensions
|
|
139
138
|
}, /*#__PURE__*/React.createElement(CardLoading, null));
|