@atlaskit/editor-plugin-card 18.3.2 → 18.4.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 +14 -0
- package/dist/cjs/ui/PasteDisplayAsMenu.js +62 -16
- package/dist/cjs/ui/nativeEmbedNode.js +132 -0
- package/dist/cjs/ui/pasteDisplayAsUtils.js +86 -23
- package/dist/es2019/ui/PasteDisplayAsMenu.js +60 -16
- package/dist/es2019/ui/nativeEmbedNode.js +132 -0
- package/dist/es2019/ui/pasteDisplayAsUtils.js +78 -22
- package/dist/esm/ui/PasteDisplayAsMenu.js +62 -16
- package/dist/esm/ui/nativeEmbedNode.js +125 -0
- package/dist/esm/ui/pasteDisplayAsUtils.js +85 -23
- package/dist/types/ui/nativeEmbedNode.d.ts +43 -0
- package/dist/types/ui/pasteDisplayAsUtils.d.ts +17 -2
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
/**
|
|
5
|
+
* A native embed is an `extension` node that `editor-plugin-native-embeds` builds from
|
|
6
|
+
* embedCard ADF (via the `embedCardNodeTransformer` registered on the card plugin).
|
|
7
|
+
* A 1P link that resolves to an embed appearance — a whiteboard, page, slide or
|
|
8
|
+
* database — therefore lands in the document as one of these rather than as an
|
|
9
|
+
* `embedCard`, so card node types alone are not enough to describe what was pasted.
|
|
10
|
+
*
|
|
11
|
+
* `editor-plugin-native-embeds` owns the equivalent predicate, but the card plugin
|
|
12
|
+
* cannot depend on it: that would close the cycle
|
|
13
|
+
* editor-plugin-card -> editor-plugin-native-embeds -> editor-plugin-card.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isNativeEmbedNode: (node: PMNode | null | undefined) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Reads the embedded URL from a native embed node. The URL is stored in
|
|
18
|
+
* `parameters.macroParams`, where values may be wrapped (`{ value }`) or bare, and is
|
|
19
|
+
* mirrored in `parameters.macroMetadata` so it survives a revert to a card.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getNativeEmbedUrl: (node: PMNode) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Whether a native embed at `pos` can be replaced by the given appearance. `url` and
|
|
24
|
+
* `inline` both become a paragraph, `block` becomes a blockCard.
|
|
25
|
+
*/
|
|
26
|
+
export declare const isNativeEmbedAppearanceSupported: ({ editorView, pos, appearance, }: {
|
|
27
|
+
appearance: 'url' | 'inline' | 'block';
|
|
28
|
+
editorView: EditorView;
|
|
29
|
+
pos: number;
|
|
30
|
+
}) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces a native embed with a link, an inline card or a block card. Mirrors
|
|
33
|
+
* `setNativeEmbedAppearance` in `editor-plugin-native-embeds`, which cannot be reused
|
|
34
|
+
* here because of the package cycle described on `isNativeEmbedNode`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const changeNativeEmbedAppearance: ({ editorView, pos, node, appearance, url, editorAnalyticsApi, }: {
|
|
37
|
+
appearance: 'url' | 'inline' | 'block';
|
|
38
|
+
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
39
|
+
editorView: EditorView;
|
|
40
|
+
node: PMNode;
|
|
41
|
+
pos: number;
|
|
42
|
+
url: string;
|
|
43
|
+
}) => boolean;
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const DISPLAY_AS_OPTIONS: readonly ['url', 'inline', 'block', 'embed'];
|
|
3
3
|
export type DisplayAsOption = (typeof DISPLAY_AS_OPTIONS)[number];
|
|
4
|
-
export
|
|
4
|
+
export type CardAtPasteRange = {
|
|
5
5
|
appearance: Exclude<DisplayAsOption, 'url'>;
|
|
6
|
+
/**
|
|
7
|
+
* True when the node is a native embed rather than a card node. It displays as an
|
|
8
|
+
* embed, but the card commands cannot operate on it — see `nativeEmbedNode.ts`.
|
|
9
|
+
*/
|
|
10
|
+
isNativeEmbed?: boolean;
|
|
6
11
|
pos: number;
|
|
7
|
-
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Finds the card that a paste produced.
|
|
15
|
+
*
|
|
16
|
+
* The paste range is recorded when the paste happens and then mapped through every later
|
|
17
|
+
* transaction, so by the time the link has resolved into a card the range can point just
|
|
18
|
+
* past that card. `pastedUrl` resolves the ambiguity: when it is known, a candidate
|
|
19
|
+
* holding that URL wins over one that merely sits in the range, which stops a pre-existing
|
|
20
|
+
* neighbouring card from being reported as the pasted one.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getCardAtPasteRange: (state: EditorState, pasteStartPos: number, pasteEndPos: number, pastedUrl?: string) => CardAtPasteRange | undefined;
|