@atlaskit/editor-plugin-card 4.5.16 → 4.5.18
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 +12 -0
- package/dist/cjs/nodeviews/blockCard.js +19 -6
- package/dist/cjs/nodeviews/embedCard.js +16 -1
- package/dist/cjs/nodeviews/inlineCard.js +17 -5
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/cjs/pm-plugins/actions.js +12 -3
- package/dist/cjs/pm-plugins/doc.js +5 -25
- package/dist/cjs/pm-plugins/reducers.js +13 -0
- package/dist/cjs/pm-plugins/util/resolve.js +2 -8
- package/dist/cjs/pm-plugins/utils.js +1 -4
- package/dist/cjs/ui/EditLinkToolbar.js +2 -8
- package/dist/cjs/ui/ResizableEmbedCard.js +1 -1
- package/dist/cjs/ui/analytics/events-from-tr.js +0 -3
- package/dist/cjs/ui/analytics/utils.js +1 -4
- package/dist/cjs/ui/editDatasourceAction.js +1 -4
- package/dist/cjs/ui/toolbar.js +7 -28
- package/dist/es2019/nodeviews/blockCard.js +20 -7
- package/dist/es2019/nodeviews/embedCard.js +17 -2
- package/dist/es2019/nodeviews/inlineCard.js +21 -7
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -1
- package/dist/es2019/pm-plugins/actions.js +7 -2
- package/dist/es2019/pm-plugins/doc.js +7 -33
- package/dist/es2019/pm-plugins/reducers.js +12 -0
- package/dist/es2019/pm-plugins/util/resolve.js +2 -8
- package/dist/es2019/pm-plugins/utils.js +2 -8
- package/dist/es2019/ui/EditLinkToolbar.js +2 -8
- package/dist/es2019/ui/ResizableEmbedCard.js +1 -1
- package/dist/es2019/ui/analytics/events-from-tr.js +0 -3
- package/dist/es2019/ui/analytics/utils.js +1 -4
- package/dist/es2019/ui/editDatasourceAction.js +1 -4
- package/dist/es2019/ui/toolbar.js +7 -28
- package/dist/esm/nodeviews/blockCard.js +20 -7
- package/dist/esm/nodeviews/embedCard.js +17 -2
- package/dist/esm/nodeviews/inlineCard.js +19 -7
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/esm/pm-plugins/actions.js +11 -2
- package/dist/esm/pm-plugins/doc.js +5 -25
- package/dist/esm/pm-plugins/reducers.js +13 -0
- package/dist/esm/pm-plugins/util/resolve.js +2 -8
- package/dist/esm/pm-plugins/utils.js +1 -4
- package/dist/esm/ui/EditLinkToolbar.js +2 -8
- package/dist/esm/ui/ResizableEmbedCard.js +1 -1
- package/dist/esm/ui/analytics/events-from-tr.js +0 -3
- package/dist/esm/ui/analytics/utils.js +1 -4
- package/dist/esm/ui/editDatasourceAction.js +1 -4
- package/dist/esm/ui/toolbar.js +7 -28
- package/dist/types/nodeviews/blockCard.d.ts +8 -2
- package/dist/types/nodeviews/embedCard.d.ts +8 -2
- package/dist/types/nodeviews/genericCard.d.ts +3 -1
- package/dist/types/pm-plugins/actions.d.ts +2 -1
- package/dist/types/pm-plugins/util/state.d.ts +1 -0
- package/dist/types/types/index.d.ts +7 -1
- package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +8 -2
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +8 -2
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +7 -1
- package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
- package/package.json +26 -22
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
|
+
import uuid from 'uuid/v4';
|
|
5
6
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
6
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
8
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -10,7 +11,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
10
11
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
11
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
13
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
14
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
15
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
15
16
|
import { Card } from './genericCard';
|
|
16
17
|
const CardInner = ({
|
|
@@ -151,7 +152,8 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
151
152
|
return view.dispatch(registerCard({
|
|
152
153
|
title,
|
|
153
154
|
url,
|
|
154
|
-
pos
|
|
155
|
+
pos,
|
|
156
|
+
id: this.props.id
|
|
155
157
|
})(view.state.tr));
|
|
156
158
|
})();
|
|
157
159
|
try {
|
|
@@ -332,6 +334,7 @@ const WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
|
|
|
332
334
|
export class EmbedCard extends ReactNodeView {
|
|
333
335
|
constructor(...args) {
|
|
334
336
|
super(...args);
|
|
337
|
+
_defineProperty(this, "id", uuid());
|
|
335
338
|
_defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
|
|
336
339
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
337
340
|
});
|
|
@@ -381,6 +384,18 @@ export class EmbedCard extends ReactNodeView {
|
|
|
381
384
|
destroy() {
|
|
382
385
|
var _this$unsubscribe;
|
|
383
386
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
387
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
388
|
+
this.removeCard();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
removeCard() {
|
|
392
|
+
const {
|
|
393
|
+
tr
|
|
394
|
+
} = this.view.state;
|
|
395
|
+
removeCard({
|
|
396
|
+
id: this.id
|
|
397
|
+
})(tr);
|
|
398
|
+
this.view.dispatch(tr);
|
|
384
399
|
}
|
|
385
400
|
}
|
|
386
401
|
export const embedCardNodeView = ({
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
4
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
6
|
import { handleNavigation } from '@atlaskit/editor-common/link';
|
|
6
7
|
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
7
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
11
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
11
12
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
12
13
|
import OverlayWrapper from '../ui/ConfigureOverlay';
|
|
13
14
|
import { Card } from './genericCard';
|
|
@@ -29,6 +30,21 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
29
30
|
url,
|
|
30
31
|
data
|
|
31
32
|
} = node.attrs;
|
|
33
|
+
const refId = useRef(uuid());
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const id = refId.current;
|
|
36
|
+
return () => {
|
|
37
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
38
|
+
const {
|
|
39
|
+
tr
|
|
40
|
+
} = view.state;
|
|
41
|
+
removeCard({
|
|
42
|
+
id
|
|
43
|
+
})(tr);
|
|
44
|
+
view.dispatch(tr);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}, [getPos, view]);
|
|
32
48
|
const scrollContainer = useMemo(
|
|
33
49
|
// Ignored via go/ees005
|
|
34
50
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -53,7 +69,8 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
53
69
|
registerCard({
|
|
54
70
|
title,
|
|
55
71
|
url,
|
|
56
|
-
pos
|
|
72
|
+
pos,
|
|
73
|
+
id: refId.current
|
|
57
74
|
})(tr);
|
|
58
75
|
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
59
76
|
view.dispatch(tr);
|
|
@@ -159,9 +176,6 @@ export function InlineCardNodeView(props) {
|
|
|
159
176
|
}
|
|
160
177
|
export const inlineCardNodeView = ({
|
|
161
178
|
inlineCardViewProducer
|
|
162
|
-
}) => (node, view, getPos, decorations
|
|
163
|
-
// Ignored via go/ees005
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
165
|
-
) => {
|
|
179
|
+
}) => (node, view, getPos, decorations) => {
|
|
166
180
|
return inlineCardViewProducer(node, view, getPos, decorations);
|
|
167
181
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
4
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
3
5
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
4
6
|
import { InlineCard } from './inlineCard';
|
|
5
7
|
export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
@@ -19,7 +21,16 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
19
21
|
const [isInserted, setIsInserted] = useState(false);
|
|
20
22
|
const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
|
|
21
23
|
const onResolve = useCallback((tr, title) => {
|
|
22
|
-
|
|
24
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
25
|
+
const metadata = tr.getMeta(pluginKey);
|
|
26
|
+
if (metadata && metadata.type === 'REGISTER') {
|
|
27
|
+
registerRemoveOverlay(() => setIsInserted(false), metadata.info)(tr);
|
|
28
|
+
} else {
|
|
29
|
+
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
33
|
+
}
|
|
23
34
|
if (title) {
|
|
24
35
|
setIsResolvedViewRendered(true);
|
|
25
36
|
}
|
|
@@ -14,9 +14,14 @@ export const registerCard = info => tr => cardAction(tr, {
|
|
|
14
14
|
type: 'REGISTER',
|
|
15
15
|
info
|
|
16
16
|
});
|
|
17
|
-
export const
|
|
17
|
+
export const removeCard = info => tr => cardAction(tr, {
|
|
18
|
+
type: 'REMOVE_CARD',
|
|
19
|
+
info
|
|
20
|
+
});
|
|
21
|
+
export const registerRemoveOverlay = (callback, info) => tr => cardAction(tr, {
|
|
18
22
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
|
|
19
|
-
callback
|
|
23
|
+
callback,
|
|
24
|
+
info
|
|
20
25
|
});
|
|
21
26
|
export const registerSmartCardEvents = smartLinkEvents => tr => cardAction(tr, {
|
|
22
27
|
type: 'REGISTER_EVENTS',
|
|
@@ -14,8 +14,6 @@ import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, se
|
|
|
14
14
|
/**
|
|
15
15
|
* Attempt to replace the link into the respective card.
|
|
16
16
|
*/
|
|
17
|
-
// Ignored via go/ees005
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
17
|
function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
20
18
|
const {
|
|
21
19
|
inlineCard
|
|
@@ -57,10 +55,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
57
55
|
}
|
|
58
56
|
return $pos.node($pos.depth - 1).type.name;
|
|
59
57
|
}
|
|
60
|
-
export const replaceQueuedUrlWithCard = (url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent
|
|
61
|
-
// Ignored via go/ees005
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
|
-
) => (editorState, dispatch) => {
|
|
58
|
+
export const replaceQueuedUrlWithCard = (url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) => (editorState, dispatch) => {
|
|
64
59
|
const state = pluginKey.getState(editorState);
|
|
65
60
|
if (!state) {
|
|
66
61
|
return false;
|
|
@@ -144,10 +139,7 @@ export const handleFallbackWithAnalytics = (request, editorAnalyticsApi) => (sta
|
|
|
144
139
|
}
|
|
145
140
|
return true;
|
|
146
141
|
};
|
|
147
|
-
export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, appearance = 'inline'
|
|
148
|
-
// Ignored via go/ees005
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
150
|
-
) => {
|
|
142
|
+
export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, appearance = 'inline') => {
|
|
151
143
|
const {
|
|
152
144
|
schema
|
|
153
145
|
} = state;
|
|
@@ -183,10 +175,7 @@ export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, norm
|
|
|
183
175
|
}
|
|
184
176
|
return queueCards(requests)(tr);
|
|
185
177
|
};
|
|
186
|
-
export const queueCardFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, previousAppearance
|
|
187
|
-
// Ignored via go/ees005
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
189
|
-
) => {
|
|
178
|
+
export const queueCardFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, previousAppearance) => {
|
|
190
179
|
const {
|
|
191
180
|
schema
|
|
192
181
|
} = state;
|
|
@@ -221,10 +210,7 @@ export const queueCardFromChangedTr = (state, tr, source, analyticsAction, norma
|
|
|
221
210
|
});
|
|
222
211
|
return queueCards(requests)(tr);
|
|
223
212
|
};
|
|
224
|
-
export const convertHyperlinkToSmartCard = (state, source, appearance, normalizeLinkText = true
|
|
225
|
-
// Ignored via go/ees005
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
227
|
-
) => {
|
|
213
|
+
export const convertHyperlinkToSmartCard = (state, source, appearance, normalizeLinkText = true) => {
|
|
228
214
|
const {
|
|
229
215
|
schema
|
|
230
216
|
} = state;
|
|
@@ -252,10 +238,7 @@ export const convertHyperlinkToSmartCard = (state, source, appearance, normalize
|
|
|
252
238
|
});
|
|
253
239
|
return queueCards(requests)(state.tr);
|
|
254
240
|
};
|
|
255
|
-
export const changeSelectedCardToLink = (text, href, sendAnalytics, node, pos, editorAnalyticsApi
|
|
256
|
-
// Ignored via go/ees005
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
258
|
-
) => (state, dispatch) => {
|
|
241
|
+
export const changeSelectedCardToLink = (text, href, sendAnalytics, node, pos, editorAnalyticsApi) => (state, dispatch) => {
|
|
259
242
|
const selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
260
243
|
let tr;
|
|
261
244
|
if (node && pos) {
|
|
@@ -282,10 +265,7 @@ export const changeSelectedCardToLink = (text, href, sendAnalytics, node, pos, e
|
|
|
282
265
|
}
|
|
283
266
|
return true;
|
|
284
267
|
};
|
|
285
|
-
export const changeSelectedCardToLinkFallback = (text, href, sendAnalytics, node, pos, editorAnalyticsApi
|
|
286
|
-
// Ignored via go/ees005
|
|
287
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
288
|
-
) => (state, dispatch) => {
|
|
268
|
+
export const changeSelectedCardToLinkFallback = (text, href, sendAnalytics, node, pos, editorAnalyticsApi) => (state, dispatch) => {
|
|
289
269
|
let tr;
|
|
290
270
|
if (node && pos) {
|
|
291
271
|
tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
|
|
@@ -334,9 +314,6 @@ function cardToLinkWithTransaction(state, text, href) {
|
|
|
334
314
|
})]), false);
|
|
335
315
|
return tr;
|
|
336
316
|
}
|
|
337
|
-
|
|
338
|
-
// Ignored via go/ees005
|
|
339
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
340
317
|
function cardNodeToLinkWithTransaction(state, text, href, node, pos) {
|
|
341
318
|
const {
|
|
342
319
|
link
|
|
@@ -505,10 +482,7 @@ export const updateCardViaDatasource = args => {
|
|
|
505
482
|
}
|
|
506
483
|
view.dispatch(tr.scrollIntoView());
|
|
507
484
|
};
|
|
508
|
-
export const insertDatasource = (state, adf, view, sourceEvent
|
|
509
|
-
// Ignored via go/ees005
|
|
510
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
511
|
-
) => {
|
|
485
|
+
export const insertDatasource = (state, adf, view, sourceEvent) => {
|
|
512
486
|
const {
|
|
513
487
|
tr,
|
|
514
488
|
selection: {
|
|
@@ -22,6 +22,12 @@ const register = (state, action) => {
|
|
|
22
22
|
cards: state.cards.filter(card => card.pos !== action.info.pos).concat(action.info)
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
const removeCard = (state, action) => {
|
|
26
|
+
return {
|
|
27
|
+
...state,
|
|
28
|
+
cards: state.cards.filter(card => card.id !== action.info.id)
|
|
29
|
+
};
|
|
30
|
+
};
|
|
25
31
|
const setProvider = (state, action) => {
|
|
26
32
|
return {
|
|
27
33
|
...state,
|
|
@@ -82,6 +88,10 @@ const clearOverlayCandidate = state => {
|
|
|
82
88
|
const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
83
89
|
return {
|
|
84
90
|
...state,
|
|
91
|
+
cards: action.info ? state.cards.filter(card => {
|
|
92
|
+
var _action$info;
|
|
93
|
+
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
94
|
+
}).concat(action.info) : state.cards,
|
|
85
95
|
removeOverlay: action.callback
|
|
86
96
|
};
|
|
87
97
|
};
|
|
@@ -116,6 +126,8 @@ export default ((state, action) => {
|
|
|
116
126
|
return resolve(state, action);
|
|
117
127
|
case 'REGISTER':
|
|
118
128
|
return register(state, action);
|
|
129
|
+
case 'REMOVE_CARD':
|
|
130
|
+
return removeCard(state, action);
|
|
119
131
|
case 'REGISTER_EVENTS':
|
|
120
132
|
return registerEvents(state, action);
|
|
121
133
|
case 'SET_DATASOURCE_TABLE_REF':
|
|
@@ -31,10 +31,7 @@ const isFreshlyPastedOnNewLine = view => {
|
|
|
31
31
|
// ============================================================================ //
|
|
32
32
|
// Used for all interactions with the EditorCardProvider.
|
|
33
33
|
// ============================================================================ //
|
|
34
|
-
export const resolveWithProvider = (view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent
|
|
35
|
-
// Ignored via go/ees005
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
37
|
-
) => {
|
|
34
|
+
export const resolveWithProvider = (view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent) => {
|
|
38
35
|
const isEmbedFriendlyLocation = fg('hardcoded-embeds-only-on-new-line') ? isFreshlyPastedOnNewLine(view) : true;
|
|
39
36
|
|
|
40
37
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
@@ -64,10 +61,7 @@ const updateCardType = (resolvedCard, options) => {
|
|
|
64
61
|
resolvedCard.type = 'inlineCard';
|
|
65
62
|
}
|
|
66
63
|
};
|
|
67
|
-
const handleResolved = (view, request, editorAnalyticsApi, createAnalyticsEvent, options
|
|
68
|
-
// Ignored via go/ees005
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
70
|
-
) => resolvedCard => {
|
|
64
|
+
const handleResolved = (view, request, editorAnalyticsApi, createAnalyticsEvent, options) => resolvedCard => {
|
|
71
65
|
updateCardType(resolvedCard, options);
|
|
72
66
|
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent)(view.state, view.dispatch);
|
|
73
67
|
return resolvedCard;
|
|
@@ -47,10 +47,7 @@ export const findCardInfo = state => {
|
|
|
47
47
|
}
|
|
48
48
|
return pluginState.cards.find(cardInfo => cardInfo.pos === state.selection.from);
|
|
49
49
|
};
|
|
50
|
-
const isAppearanceSupportedInParent = (currentNodePosition, editorState, fragment, currentAppearance
|
|
51
|
-
// Ignored via go/ees005
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
53
|
-
) => {
|
|
50
|
+
const isAppearanceSupportedInParent = (currentNodePosition, editorState, fragment, currentAppearance) => {
|
|
54
51
|
const resolvedPosition = editorState.doc.resolve(currentNodePosition);
|
|
55
52
|
const parent = currentAppearance === 'embed' || currentAppearance === 'block' ? resolvedPosition.node() : resolvedPosition.node(-1);
|
|
56
53
|
return parent && parent.type.validContent(fragment);
|
|
@@ -118,10 +115,7 @@ export const focusEditorView = editorView => {
|
|
|
118
115
|
editorView.focus();
|
|
119
116
|
}
|
|
120
117
|
};
|
|
121
|
-
export const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards, disableOverlay = false
|
|
122
|
-
// Ignored via go/ees005
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
124
|
-
) => {
|
|
118
|
+
export const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards, disableOverlay = false) => {
|
|
125
119
|
var _editorState$selectio, _editorState$selectio2, _editorState$selectio3;
|
|
126
120
|
const getPosFunction = typeof getPos !== 'boolean' ? getPos : undefined;
|
|
127
121
|
const linkPosition = getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction();
|
|
@@ -75,10 +75,7 @@ export class EditLinkToolbar extends React.Component {
|
|
|
75
75
|
// via the floating toolbar
|
|
76
76
|
,
|
|
77
77
|
invokeMethod: INPUT_METHOD.FLOATING_TB,
|
|
78
|
-
lpLinkPicker: lpLinkPicker
|
|
79
|
-
// Ignored via go/ees005
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
81
|
-
,
|
|
78
|
+
lpLinkPicker: lpLinkPicker,
|
|
82
79
|
onSubmit: (href, title, displayText, inputMethod, analytic) => {
|
|
83
80
|
this.hideLinkToolbar();
|
|
84
81
|
if (onSubmit) {
|
|
@@ -153,10 +150,7 @@ export const buildEditLinkToolbar = ({
|
|
|
153
150
|
text: displayInfo.title || '',
|
|
154
151
|
node: node,
|
|
155
152
|
lpLinkPicker: lpLinkPicker,
|
|
156
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector
|
|
157
|
-
// Ignored via go/ees005
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
159
|
-
,
|
|
153
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector,
|
|
160
154
|
onSubmit: (newHref, newText, inputMethod, analytic) => {
|
|
161
155
|
const urlChanged = newHref !== displayInfo.url;
|
|
162
156
|
const titleChanged = newText !== displayInfo.title;
|
|
@@ -296,7 +296,7 @@ export default class ResizableEmbedCard extends React.Component {
|
|
|
296
296
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
297
297
|
display: 'block',
|
|
298
298
|
/* Fixes extra padding problem in Firefox */
|
|
299
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
299
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
|
|
300
300
|
fontSize: 0,
|
|
301
301
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
|
|
302
302
|
lineHeight: 0,
|
|
@@ -74,9 +74,6 @@ export const findChanged = (tr, state) => {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
// Ignored via go/ees005
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
77
|
stepMap.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
81
78
|
var _tr$docs2;
|
|
82
79
|
const before = tr.docs[i];
|
|
@@ -81,10 +81,7 @@ export const findAtPositions = (tr, positions) => {
|
|
|
81
81
|
}
|
|
82
82
|
return entities;
|
|
83
83
|
};
|
|
84
|
-
export const findInNodeRange = (doc, from, to, predicate
|
|
85
|
-
// Ignored via go/ees005
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
87
|
-
) => {
|
|
84
|
+
export const findInNodeRange = (doc, from, to, predicate) => {
|
|
88
85
|
const entities = [];
|
|
89
86
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
90
87
|
if (predicate(node)) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { getDatasourceType } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { showDatasourceModal } from '../pm-plugins/actions';
|
|
4
|
-
export const editDatasource = (datasourceId, editorAnalyticsApi, appearance, extensionKey
|
|
5
|
-
// Ignored via go/ees005
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
7
|
-
) => (state, dispatch) => {
|
|
4
|
+
export const editDatasource = (datasourceId, editorAnalyticsApi, appearance, extensionKey) => (state, dispatch) => {
|
|
8
5
|
const datasourceType = getDatasourceType(datasourceId);
|
|
9
6
|
if (dispatch && datasourceType) {
|
|
10
7
|
const {
|
|
@@ -96,10 +96,7 @@ export const openLinkSettings = editorAnalyticsApi => (state, dispatch) => {
|
|
|
96
96
|
}
|
|
97
97
|
return true;
|
|
98
98
|
};
|
|
99
|
-
export const floatingToolbar = (cardOptions, lpLinkPicker, linkPickerOptions, pluginInjectionApi, disableFloatingToolbar
|
|
100
|
-
// Ignored via go/ees005
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
102
|
-
) => {
|
|
99
|
+
export const floatingToolbar = (cardOptions, lpLinkPicker, linkPickerOptions, pluginInjectionApi, disableFloatingToolbar) => {
|
|
103
100
|
return (state, intl, providerFactory) => {
|
|
104
101
|
if (disableFloatingToolbar) {
|
|
105
102
|
return;
|
|
@@ -164,10 +161,7 @@ const unlinkCard = (node, state, editorAnalyticsApi) => {
|
|
|
164
161
|
}
|
|
165
162
|
return () => false;
|
|
166
163
|
};
|
|
167
|
-
const buildAlignmentOptions = (state, intl, widthPluginDependencyApi, analyticsApi, cardOptions
|
|
168
|
-
// Ignored via go/ees005
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
170
|
-
) => {
|
|
164
|
+
const buildAlignmentOptions = (state, intl, widthPluginDependencyApi, analyticsApi, cardOptions) => {
|
|
171
165
|
return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, analyticsApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
|
|
172
166
|
};
|
|
173
167
|
const withToolbarMetadata = command => commandWithMetadata(command, {
|
|
@@ -188,10 +182,7 @@ const getToolbarViewedItem = (url, display) => {
|
|
|
188
182
|
})
|
|
189
183
|
}];
|
|
190
184
|
};
|
|
191
|
-
const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi
|
|
192
|
-
// Ignored via go/ees005
|
|
193
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
194
|
-
) => node => {
|
|
185
|
+
const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) => node => {
|
|
195
186
|
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs, _node$attrs$datasourc;
|
|
196
187
|
const {
|
|
197
188
|
url
|
|
@@ -384,10 +375,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
384
375
|
return toolbarItems;
|
|
385
376
|
}
|
|
386
377
|
};
|
|
387
|
-
const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi
|
|
388
|
-
// Ignored via go/ees005
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
390
|
-
) => {
|
|
378
|
+
const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi) => {
|
|
391
379
|
return node.type === inlineCard ? [{
|
|
392
380
|
id: 'editor.link.unlink',
|
|
393
381
|
focusEditoronEnter: true,
|
|
@@ -412,10 +400,7 @@ export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink)
|
|
|
412
400
|
target: '_blank'
|
|
413
401
|
};
|
|
414
402
|
};
|
|
415
|
-
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance
|
|
416
|
-
// Ignored via go/ees005
|
|
417
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
418
|
-
) => {
|
|
403
|
+
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance) => {
|
|
419
404
|
var _node$attrs2;
|
|
420
405
|
const toolbarItems = [];
|
|
421
406
|
const canShowAppearanceSwitch = () => {
|
|
@@ -524,17 +509,11 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
524
509
|
});
|
|
525
510
|
return toolbarItems;
|
|
526
511
|
};
|
|
527
|
-
export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled
|
|
528
|
-
// Ignored via go/ees005
|
|
529
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
530
|
-
) => {
|
|
512
|
+
export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled) => {
|
|
531
513
|
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
|
|
532
514
|
};
|
|
533
515
|
export const getStartingToolbarItems = (options, api) => {
|
|
534
|
-
return (intl, link, onEditLink, metadata
|
|
535
|
-
// Ignored via go/ees005
|
|
536
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
537
|
-
) => {
|
|
516
|
+
return (intl, link, onEditLink, metadata) => {
|
|
538
517
|
const editLinkItem = options.allowDatasource ? [{
|
|
539
518
|
type: 'custom',
|
|
540
519
|
fallback: [],
|
|
@@ -10,13 +10,14 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import rafSchedule from 'raf-schd';
|
|
13
|
+
import uuid from 'uuid/v4';
|
|
13
14
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
14
15
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
15
16
|
import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
18
19
|
import { Datasource } from '../nodeviews/datasource';
|
|
19
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
20
|
+
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
20
21
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
21
22
|
import { Card } from './genericCard';
|
|
22
23
|
|
|
@@ -48,7 +49,8 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
48
49
|
view.dispatch(registerCard({
|
|
49
50
|
title: title,
|
|
50
51
|
url: url,
|
|
51
|
-
pos: pos
|
|
52
|
+
pos: pos,
|
|
53
|
+
id: _this.props.id
|
|
52
54
|
})(view.state.tr));
|
|
53
55
|
})();
|
|
54
56
|
});
|
|
@@ -114,6 +116,7 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
114
116
|
args[_key] = arguments[_key];
|
|
115
117
|
}
|
|
116
118
|
_this2 = _callSuper(this, BlockCard, [].concat(args));
|
|
119
|
+
_defineProperty(_this2, "id", uuid());
|
|
117
120
|
_defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
118
121
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
119
122
|
});
|
|
@@ -171,7 +174,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
171
174
|
getPos: this.getPos,
|
|
172
175
|
actionOptions: actionOptions,
|
|
173
176
|
pluginInjectionApi: pluginInjectionApi,
|
|
174
|
-
onClickCallback: onClickCallback
|
|
177
|
+
onClickCallback: onClickCallback,
|
|
178
|
+
id: this.id
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
}, {
|
|
@@ -179,6 +183,18 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
179
183
|
value: function destroy() {
|
|
180
184
|
var _this$unsubscribe;
|
|
181
185
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
186
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
187
|
+
this.removeCard();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "removeCard",
|
|
192
|
+
value: function removeCard() {
|
|
193
|
+
var tr = this.view.state.tr;
|
|
194
|
+
_removeCard({
|
|
195
|
+
id: this.id
|
|
196
|
+
})(tr);
|
|
197
|
+
this.view.dispatch(tr);
|
|
182
198
|
}
|
|
183
199
|
}]);
|
|
184
200
|
}(ReactNodeView);
|
|
@@ -189,10 +205,7 @@ export var blockCardNodeView = function blockCardNodeView(_ref3) {
|
|
|
189
205
|
onClickCallback = _ref3.onClickCallback,
|
|
190
206
|
allowDatasource = _ref3.allowDatasource,
|
|
191
207
|
inlineCardViewProducer = _ref3.inlineCardViewProducer;
|
|
192
|
-
return function (node, view, getPos, decorations
|
|
193
|
-
// Ignored via go/ees005
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
195
|
-
) {
|
|
208
|
+
return function (node, view, getPos, decorations) {
|
|
196
209
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
197
210
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
198
211
|
var reactComponentProps = {
|
|
@@ -13,6 +13,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import rafSchedule from 'raf-schd';
|
|
16
|
+
import uuid from 'uuid/v4';
|
|
16
17
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
17
18
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
19
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -21,7 +22,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
21
22
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
22
23
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
24
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
25
|
+
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
25
26
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
26
27
|
import { Card } from './genericCard';
|
|
27
28
|
var CardInner = function CardInner(_ref) {
|
|
@@ -155,7 +156,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
155
156
|
return view.dispatch(registerCard({
|
|
156
157
|
title: title,
|
|
157
158
|
url: url,
|
|
158
|
-
pos: pos
|
|
159
|
+
pos: pos,
|
|
160
|
+
id: _this.props.id
|
|
159
161
|
})(view.state.tr));
|
|
160
162
|
})();
|
|
161
163
|
try {
|
|
@@ -338,6 +340,7 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
338
340
|
args[_key] = arguments[_key];
|
|
339
341
|
}
|
|
340
342
|
_this2 = _callSuper(this, EmbedCard, [].concat(args));
|
|
343
|
+
_defineProperty(_this2, "id", uuid());
|
|
341
344
|
_defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
342
345
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
343
346
|
});
|
|
@@ -398,6 +401,18 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
398
401
|
value: function destroy() {
|
|
399
402
|
var _this$unsubscribe;
|
|
400
403
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
404
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
405
|
+
this.removeCard();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
key: "removeCard",
|
|
410
|
+
value: function removeCard() {
|
|
411
|
+
var tr = this.view.state.tr;
|
|
412
|
+
_removeCard({
|
|
413
|
+
id: this.id
|
|
414
|
+
})(tr);
|
|
415
|
+
this.view.dispatch(tr);
|
|
401
416
|
}
|
|
402
417
|
}]);
|
|
403
418
|
}(ReactNodeView);
|