@atlaskit/editor-plugin-card 0.14.3 → 0.14.4
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 +6 -0
- package/dist/cjs/ui/InlineCardOverlay/index.js +6 -1
- package/dist/cjs/ui/InlineCardOverlay/utils.js +6 -1
- package/dist/es2019/ui/InlineCardOverlay/index.js +7 -2
- package/dist/es2019/ui/InlineCardOverlay/utils.js +5 -0
- package/dist/esm/ui/InlineCardOverlay/index.js +7 -2
- package/dist/esm/ui/InlineCardOverlay/utils.js +5 -0
- package/dist/types/ui/InlineCardOverlay/utils.d.ts +1 -0
- package/dist/types-ts4.5/ui/InlineCardOverlay/utils.d.ts +1 -0
- package/package.json +1 -1
- package/tmp/api-report-tmp.d.ts +0 -199
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 0.14.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#56625](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/56625) [`1df300977e9a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1df300977e9a) - [ux] Always show link icon when showing 'change view' overlay in editor. Do not show if the overlay will cover the whole link including the icon.
|
|
8
|
+
|
|
3
9
|
## 0.14.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -28,6 +28,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
28
28
|
var DEBOUNCE_IN_MS = 5;
|
|
29
29
|
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
30
30
|
var PADDING_IN_PX = 2;
|
|
31
|
+
var ICON_WIDTH_IN_PX = 16;
|
|
31
32
|
var OVERLAY_CLASSNAME = 'ak-editor-card-overlay';
|
|
32
33
|
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
33
34
|
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
@@ -143,10 +144,14 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
143
144
|
return;
|
|
144
145
|
}
|
|
145
146
|
try {
|
|
147
|
+
var oneLine = (0, _utils2.isOneLine)(containerRef.current, marker);
|
|
148
|
+
|
|
146
149
|
// Get the width of the available space to display overlay.
|
|
147
150
|
// This is the width of the inline link itself. If the inline
|
|
148
151
|
// is wrapped to the next line, this is width of the last line.
|
|
149
|
-
var availableWidth = (0, _utils2.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX
|
|
152
|
+
var availableWidth = (0, _utils2.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
|
|
153
|
+
// Always leave at least the icon visible
|
|
154
|
+
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
150
155
|
|
|
151
156
|
// If available width is less than the min width of overlay, don't show overlay.
|
|
152
157
|
var canShowOverlay = availableWidth > minOverlayWidth.current;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getOverlayWidths = exports.getInlineCardAvailableWidth = exports.getChildElement = void 0;
|
|
6
|
+
exports.isOneLine = exports.getOverlayWidths = exports.getInlineCardAvailableWidth = exports.getChildElement = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Find a child element inside a ref.
|
|
9
9
|
*/
|
|
@@ -20,6 +20,11 @@ var getInlineCardAvailableWidth = exports.getInlineCardAvailableWidth = function
|
|
|
20
20
|
var end = endEl.getBoundingClientRect().left;
|
|
21
21
|
return end - start;
|
|
22
22
|
};
|
|
23
|
+
var isOneLine = exports.isOneLine = function isOneLine(startEl, endEl) {
|
|
24
|
+
var start = startEl.getBoundingClientRect().top;
|
|
25
|
+
var end = endEl.getBoundingClientRect().top;
|
|
26
|
+
return start === end;
|
|
27
|
+
};
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Get max and min width of an overlay.
|
|
@@ -10,10 +10,11 @@ import HipchatChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
|
10
10
|
import HipchatChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
|
|
11
11
|
import { N20A, N800 } from '@atlaskit/theme/colors';
|
|
12
12
|
import { messages } from '../../messages';
|
|
13
|
-
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths } from './utils';
|
|
13
|
+
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
14
14
|
const DEBOUNCE_IN_MS = 5;
|
|
15
15
|
const ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
16
16
|
const PADDING_IN_PX = 2;
|
|
17
|
+
const ICON_WIDTH_IN_PX = 16;
|
|
17
18
|
const OVERLAY_CLASSNAME = 'ak-editor-card-overlay';
|
|
18
19
|
const OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
19
20
|
const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
@@ -128,10 +129,14 @@ const InlineCardOverlay = ({
|
|
|
128
129
|
return;
|
|
129
130
|
}
|
|
130
131
|
try {
|
|
132
|
+
const oneLine = isOneLine(containerRef.current, marker);
|
|
133
|
+
|
|
131
134
|
// Get the width of the available space to display overlay.
|
|
132
135
|
// This is the width of the inline link itself. If the inline
|
|
133
136
|
// is wrapped to the next line, this is width of the last line.
|
|
134
|
-
const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX
|
|
137
|
+
const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
138
|
+
// Always leave at least the icon visible
|
|
139
|
+
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
135
140
|
|
|
136
141
|
// If available width is less than the min width of overlay, don't show overlay.
|
|
137
142
|
const canShowOverlay = availableWidth > minOverlayWidth.current;
|
|
@@ -12,6 +12,11 @@ export const getInlineCardAvailableWidth = (startEl, endEl) => {
|
|
|
12
12
|
const end = endEl.getBoundingClientRect().left;
|
|
13
13
|
return end - start;
|
|
14
14
|
};
|
|
15
|
+
export const isOneLine = (startEl, endEl) => {
|
|
16
|
+
const start = startEl.getBoundingClientRect().top;
|
|
17
|
+
const end = endEl.getBoundingClientRect().top;
|
|
18
|
+
return start === end;
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* Get max and min width of an overlay.
|
|
@@ -16,10 +16,11 @@ import HipchatChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
|
16
16
|
import HipchatChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
|
|
17
17
|
import { N20A, N800 } from '@atlaskit/theme/colors';
|
|
18
18
|
import { messages } from '../../messages';
|
|
19
|
-
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths } from './utils';
|
|
19
|
+
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
20
20
|
var DEBOUNCE_IN_MS = 5;
|
|
21
21
|
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
22
22
|
var PADDING_IN_PX = 2;
|
|
23
|
+
var ICON_WIDTH_IN_PX = 16;
|
|
23
24
|
var OVERLAY_CLASSNAME = 'ak-editor-card-overlay';
|
|
24
25
|
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
25
26
|
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
@@ -135,10 +136,14 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
137
138
|
try {
|
|
139
|
+
var oneLine = isOneLine(containerRef.current, marker);
|
|
140
|
+
|
|
138
141
|
// Get the width of the available space to display overlay.
|
|
139
142
|
// This is the width of the inline link itself. If the inline
|
|
140
143
|
// is wrapped to the next line, this is width of the last line.
|
|
141
|
-
var availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX
|
|
144
|
+
var availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
145
|
+
// Always leave at least the icon visible
|
|
146
|
+
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
142
147
|
|
|
143
148
|
// If available width is less than the min width of overlay, don't show overlay.
|
|
144
149
|
var canShowOverlay = availableWidth > minOverlayWidth.current;
|
|
@@ -14,6 +14,11 @@ export var getInlineCardAvailableWidth = function getInlineCardAvailableWidth(st
|
|
|
14
14
|
var end = endEl.getBoundingClientRect().left;
|
|
15
15
|
return end - start;
|
|
16
16
|
};
|
|
17
|
+
export var isOneLine = function isOneLine(startEl, endEl) {
|
|
18
|
+
var start = startEl.getBoundingClientRect().top;
|
|
19
|
+
var end = endEl.getBoundingClientRect().top;
|
|
20
|
+
return start === end;
|
|
21
|
+
};
|
|
17
22
|
|
|
18
23
|
/**
|
|
19
24
|
* Get max and min width of an overlay.
|
|
@@ -7,6 +7,7 @@ export declare const getChildElement: (ref: React.RefObject<HTMLElement>, select
|
|
|
7
7
|
* (Mainly here to make the component unit testable.)
|
|
8
8
|
*/
|
|
9
9
|
export declare const getInlineCardAvailableWidth: (startEl: HTMLElement, endEl: HTMLElement) => number;
|
|
10
|
+
export declare const isOneLine: (startEl: HTMLElement, endEl: HTMLElement) => boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Get max and min width of an overlay.
|
|
12
13
|
* (Mainly here to make the component unit testable.)
|
|
@@ -7,6 +7,7 @@ export declare const getChildElement: (ref: React.RefObject<HTMLElement>, select
|
|
|
7
7
|
* (Mainly here to make the component unit testable.)
|
|
8
8
|
*/
|
|
9
9
|
export declare const getInlineCardAvailableWidth: (startEl: HTMLElement, endEl: HTMLElement) => number;
|
|
10
|
+
export declare const isOneLine: (startEl: HTMLElement, endEl: HTMLElement) => boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Get max and min width of an overlay.
|
|
12
13
|
* (Mainly here to make the component unit testable.)
|
package/package.json
CHANGED
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/editor-plugin-card"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
9
|
-
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
10
|
-
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
11
|
-
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
12
|
-
import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
13
|
-
import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
14
|
-
import type { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
15
|
-
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
16
|
-
import type { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
17
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
18
|
-
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
19
|
-
import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
20
|
-
import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
21
|
-
import type { LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
22
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
23
|
-
import type { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
|
|
24
|
-
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
25
|
-
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
26
|
-
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
27
|
-
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
|
-
|
|
29
|
-
// @public (undocumented)
|
|
30
|
-
type CardInfo = {
|
|
31
|
-
title?: string;
|
|
32
|
-
url?: string;
|
|
33
|
-
pos: number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// @public (undocumented)
|
|
37
|
-
export type CardPlugin = NextEditorPlugin<'card', {
|
|
38
|
-
pluginConfiguration: CardPluginOptions;
|
|
39
|
-
dependencies: [
|
|
40
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
41
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
42
|
-
WidthPlugin,
|
|
43
|
-
DecorationsPlugin,
|
|
44
|
-
GridPlugin,
|
|
45
|
-
FloatingToolbarPlugin,
|
|
46
|
-
HyperlinkPlugin
|
|
47
|
-
];
|
|
48
|
-
sharedState: CardPluginState | null;
|
|
49
|
-
actions: CardPluginActions;
|
|
50
|
-
}>;
|
|
51
|
-
|
|
52
|
-
// @public
|
|
53
|
-
export const cardPlugin: CardPlugin;
|
|
54
|
-
|
|
55
|
-
// @public (undocumented)
|
|
56
|
-
type CardPluginEvent = DatasourceEvent | LinkEvent;
|
|
57
|
-
|
|
58
|
-
// @public (undocumented)
|
|
59
|
-
type CardPluginOptions = CardOptions & {
|
|
60
|
-
editorAppearance?: EditorAppearance;
|
|
61
|
-
platform: 'mobile' | 'web';
|
|
62
|
-
fullWidthMode?: boolean;
|
|
63
|
-
linkPicker?: LinkPickerOptions;
|
|
64
|
-
cardPluginEvents?: EditorCardPluginEvents<CardPluginEvent>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// @public (undocumented)
|
|
68
|
-
type CardPluginState = {
|
|
69
|
-
requests: Request_2[];
|
|
70
|
-
provider: CardProvider | null;
|
|
71
|
-
cards: CardInfo[];
|
|
72
|
-
showLinkingToolbar: boolean;
|
|
73
|
-
smartLinkEvents?: SmartLinkEvents;
|
|
74
|
-
editorAppearance?: EditorAppearance;
|
|
75
|
-
showDatasourceModal: boolean;
|
|
76
|
-
datasourceModalType?: DatasourceModalType;
|
|
77
|
-
datasourceTableRef?: HTMLElement;
|
|
78
|
-
layout?: DatasourceTableLayout;
|
|
79
|
-
inlineCardAwarenessCandidatePosition?: number;
|
|
80
|
-
overlayCandidatePosition?: number;
|
|
81
|
-
removeOverlay?: () => void;
|
|
82
|
-
selectedInlineLinkPosition?: number;
|
|
83
|
-
allowEmbeds?: boolean;
|
|
84
|
-
allowBlockCards?: boolean;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// @public (undocumented)
|
|
88
|
-
type DatasourceCreatedEvent = {
|
|
89
|
-
event: EVENT.CREATED;
|
|
90
|
-
subject: EVENT_SUBJECT.DATASOURCE;
|
|
91
|
-
data: Metadata_2;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// @public (undocumented)
|
|
95
|
-
type DatasourceDeletedEvent = {
|
|
96
|
-
event: EVENT.DELETED;
|
|
97
|
-
subject: EVENT_SUBJECT.DATASOURCE;
|
|
98
|
-
data: Metadata_2;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// @public (undocumented)
|
|
102
|
-
type DatasourceEvent = DatasourceCreatedEvent | DatasourceDeletedEvent | DatasourceUpdatedEvent;
|
|
103
|
-
|
|
104
|
-
// @public (undocumented)
|
|
105
|
-
type DatasourceTableLayout = 'center' | 'full-width' | 'wide';
|
|
106
|
-
|
|
107
|
-
// @public (undocumented)
|
|
108
|
-
type DatasourceUpdatedEvent = {
|
|
109
|
-
event: EVENT.UPDATED;
|
|
110
|
-
subject: EVENT_SUBJECT.DATASOURCE;
|
|
111
|
-
data: Metadata_2<UpdateMetadata>;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// @public (undocumented)
|
|
115
|
-
type EditorCardPluginEvents<T> = {
|
|
116
|
-
push: (...events: T[]) => void;
|
|
117
|
-
subscribe: (listener: Subscriber<T>) => () => void;
|
|
118
|
-
flush: () => void;
|
|
119
|
-
getSize: () => number;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// @public (undocumented)
|
|
123
|
-
enum EVENT {
|
|
124
|
-
// (undocumented)
|
|
125
|
-
CREATED = "created",
|
|
126
|
-
// (undocumented)
|
|
127
|
-
DELETED = "deleted",
|
|
128
|
-
// (undocumented)
|
|
129
|
-
UPDATED = "updated"
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// @public (undocumented)
|
|
133
|
-
enum EVENT_SUBJECT {
|
|
134
|
-
// (undocumented)
|
|
135
|
-
DATASOURCE = "datasource",
|
|
136
|
-
// (undocumented)
|
|
137
|
-
LINK = "link"
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// @public
|
|
141
|
-
type LinkCreatedEvent = {
|
|
142
|
-
event: EVENT.CREATED;
|
|
143
|
-
subject: EVENT_SUBJECT.LINK;
|
|
144
|
-
data: Metadata_2;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// @public (undocumented)
|
|
148
|
-
type LinkDeletedEvent = {
|
|
149
|
-
event: EVENT.DELETED;
|
|
150
|
-
subject: EVENT_SUBJECT.LINK;
|
|
151
|
-
data: Metadata_2;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// @public (undocumented)
|
|
155
|
-
type LinkEvent = LinkCreatedEvent | LinkDeletedEvent | LinkUpdatedEvent;
|
|
156
|
-
|
|
157
|
-
// @public (undocumented)
|
|
158
|
-
type LinkUpdatedEvent = {
|
|
159
|
-
event: EVENT.UPDATED;
|
|
160
|
-
subject: EVENT_SUBJECT.LINK;
|
|
161
|
-
data: Metadata_2<UpdateMetadata>;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// @public (undocumented)
|
|
165
|
-
type Metadata_2<T = {}> = {
|
|
166
|
-
node: Node_2;
|
|
167
|
-
isUndo?: boolean;
|
|
168
|
-
isRedo?: boolean;
|
|
169
|
-
action?: string;
|
|
170
|
-
inputMethod?: string;
|
|
171
|
-
sourceEvent?: unknown;
|
|
172
|
-
nodeContext?: string;
|
|
173
|
-
} & T;
|
|
174
|
-
|
|
175
|
-
// @public (undocumented)
|
|
176
|
-
type Request_2 = {
|
|
177
|
-
pos: number;
|
|
178
|
-
url: string;
|
|
179
|
-
appearance: CardAppearance;
|
|
180
|
-
compareLinkText: boolean;
|
|
181
|
-
source: CardReplacementInputMethod;
|
|
182
|
-
previousAppearance?: 'url' | CardAppearance;
|
|
183
|
-
analyticsAction?: ACTION;
|
|
184
|
-
shouldReplaceLink?: boolean;
|
|
185
|
-
sourceEvent?: UIAnalyticsEvent | null | undefined;
|
|
186
|
-
};
|
|
187
|
-
export { Request_2 as Request }
|
|
188
|
-
|
|
189
|
-
// @public (undocumented)
|
|
190
|
-
type Subscriber<T> = (event: T) => void;
|
|
191
|
-
|
|
192
|
-
// @public (undocumented)
|
|
193
|
-
type UpdateMetadata = {
|
|
194
|
-
previousDisplay?: string;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// (No @packageDocumentation comment for this package)
|
|
198
|
-
|
|
199
|
-
```
|