@atlaskit/editor-plugin-card 18.3.1 → 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.
@@ -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 declare const getCardAtPasteRange: (state: EditorState, pasteStartPos: number, pasteEndPos: number) => {
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
- } | undefined;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "18.3.1",
3
+ "version": "18.4.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -59,7 +59,7 @@
59
59
  "@atlaskit/primitives": "^22.2.0",
60
60
  "@atlaskit/prosemirror-history": "^1.1.0",
61
61
  "@atlaskit/smart-card": "^45.16.0",
62
- "@atlaskit/tmp-editor-statsig": "^135.10.0",
62
+ "@atlaskit/tmp-editor-statsig": "^136.0.0",
63
63
  "@atlaskit/tokens": "^16.3.0",
64
64
  "@babel/runtime": "^7.0.0",
65
65
  "@emotion/react": "^11.7.1",