@atlaskit/editor-plugin-card 0.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/.eslintrc.js +15 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +7 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/messages.js +20 -0
- package/dist/cjs/nodeviews/blockCard.js +164 -0
- package/dist/cjs/nodeviews/datasource.js +173 -0
- package/dist/cjs/nodeviews/embedCard.js +398 -0
- package/dist/cjs/nodeviews/genericCard.js +118 -0
- package/dist/cjs/nodeviews/inlineCard.js +132 -0
- package/dist/cjs/plugin.js +138 -0
- package/dist/cjs/pm-plugins/actions.js +122 -0
- package/dist/cjs/pm-plugins/analytics/create-analytics-queue.js +48 -0
- package/dist/cjs/pm-plugins/analytics/events-from-tr.js +359 -0
- package/dist/cjs/pm-plugins/analytics/index.js +19 -0
- package/dist/cjs/pm-plugins/analytics/types.js +5 -0
- package/dist/cjs/pm-plugins/analytics/utils.js +178 -0
- package/dist/cjs/pm-plugins/doc.js +479 -0
- package/dist/cjs/pm-plugins/keymap.js +64 -0
- package/dist/cjs/pm-plugins/main.js +212 -0
- package/dist/cjs/pm-plugins/mountHyperlink.js +47 -0
- package/dist/cjs/pm-plugins/plugin-key.js +9 -0
- package/dist/cjs/pm-plugins/reducers.js +111 -0
- package/dist/cjs/pm-plugins/shouldReplaceLink.js +35 -0
- package/dist/cjs/pm-plugins/util/resolve.js +59 -0
- package/dist/cjs/pm-plugins/util/state.js +49 -0
- package/dist/cjs/toolbar.js +364 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/ui/DatasourceModal/ModalWithState.js +25 -0
- package/dist/cjs/ui/DatasourceModal/index.js +60 -0
- package/dist/cjs/ui/EditLinkToolbar.js +258 -0
- package/dist/cjs/ui/EditorSmartCardEvents.js +21 -0
- package/dist/cjs/ui/EditorSmartCardEventsNext.js +215 -0
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +174 -0
- package/dist/cjs/ui/LayoutButton/index.js +121 -0
- package/dist/cjs/ui/LayoutButton/types.js +5 -0
- package/dist/cjs/ui/LayoutButton/utils.js +19 -0
- package/dist/cjs/ui/LinkToolbarAppearance.js +152 -0
- package/dist/cjs/ui/ResizableEmbedCard.js +364 -0
- package/dist/cjs/ui/SmallerEditIcon.js +22 -0
- package/dist/cjs/utils.js +60 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/messages.js +13 -0
- package/dist/es2019/nodeviews/blockCard.js +131 -0
- package/dist/es2019/nodeviews/datasource.js +137 -0
- package/dist/es2019/nodeviews/embedCard.js +370 -0
- package/dist/es2019/nodeviews/genericCard.js +92 -0
- package/dist/es2019/nodeviews/inlineCard.js +113 -0
- package/dist/es2019/plugin.js +129 -0
- package/dist/es2019/pm-plugins/actions.js +57 -0
- package/dist/es2019/pm-plugins/analytics/create-analytics-queue.js +38 -0
- package/dist/es2019/pm-plugins/analytics/events-from-tr.js +339 -0
- package/dist/es2019/pm-plugins/analytics/index.js +2 -0
- package/dist/es2019/pm-plugins/analytics/types.js +1 -0
- package/dist/es2019/pm-plugins/analytics/utils.js +160 -0
- package/dist/es2019/pm-plugins/doc.js +451 -0
- package/dist/es2019/pm-plugins/keymap.js +59 -0
- package/dist/es2019/pm-plugins/main.js +208 -0
- package/dist/es2019/pm-plugins/mountHyperlink.js +37 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/reducers.js +110 -0
- package/dist/es2019/pm-plugins/shouldReplaceLink.js +25 -0
- package/dist/es2019/pm-plugins/util/resolve.js +50 -0
- package/dist/es2019/pm-plugins/util/state.js +26 -0
- package/dist/es2019/toolbar.js +359 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/DatasourceModal/ModalWithState.js +19 -0
- package/dist/es2019/ui/DatasourceModal/index.js +48 -0
- package/dist/es2019/ui/EditLinkToolbar.js +226 -0
- package/dist/es2019/ui/EditorSmartCardEvents.js +15 -0
- package/dist/es2019/ui/EditorSmartCardEventsNext.js +199 -0
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +86 -0
- package/dist/es2019/ui/LayoutButton/index.js +114 -0
- package/dist/es2019/ui/LayoutButton/types.js +1 -0
- package/dist/es2019/ui/LayoutButton/utils.js +15 -0
- package/dist/es2019/ui/LinkToolbarAppearance.js +118 -0
- package/dist/es2019/ui/ResizableEmbedCard.js +335 -0
- package/dist/es2019/ui/SmallerEditIcon.js +14 -0
- package/dist/es2019/utils.js +46 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/messages.js +13 -0
- package/dist/esm/nodeviews/blockCard.js +156 -0
- package/dist/esm/nodeviews/datasource.js +165 -0
- package/dist/esm/nodeviews/embedCard.js +389 -0
- package/dist/esm/nodeviews/genericCard.js +111 -0
- package/dist/esm/nodeviews/inlineCard.js +124 -0
- package/dist/esm/plugin.js +130 -0
- package/dist/esm/pm-plugins/actions.js +102 -0
- package/dist/esm/pm-plugins/analytics/create-analytics-queue.js +41 -0
- package/dist/esm/pm-plugins/analytics/events-from-tr.js +350 -0
- package/dist/esm/pm-plugins/analytics/index.js +2 -0
- package/dist/esm/pm-plugins/analytics/types.js +1 -0
- package/dist/esm/pm-plugins/analytics/utils.js +160 -0
- package/dist/esm/pm-plugins/doc.js +460 -0
- package/dist/esm/pm-plugins/keymap.js +58 -0
- package/dist/esm/pm-plugins/main.js +199 -0
- package/dist/esm/pm-plugins/mountHyperlink.js +39 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/reducers.js +103 -0
- package/dist/esm/pm-plugins/shouldReplaceLink.js +29 -0
- package/dist/esm/pm-plugins/util/resolve.js +52 -0
- package/dist/esm/pm-plugins/util/state.js +40 -0
- package/dist/esm/toolbar.js +350 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/DatasourceModal/ModalWithState.js +17 -0
- package/dist/esm/ui/DatasourceModal/index.js +49 -0
- package/dist/esm/ui/EditLinkToolbar.js +244 -0
- package/dist/esm/ui/EditorSmartCardEvents.js +14 -0
- package/dist/esm/ui/EditorSmartCardEventsNext.js +203 -0
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +163 -0
- package/dist/esm/ui/LayoutButton/index.js +110 -0
- package/dist/esm/ui/LayoutButton/types.js +1 -0
- package/dist/esm/ui/LayoutButton/utils.js +12 -0
- package/dist/esm/ui/LinkToolbarAppearance.js +141 -0
- package/dist/esm/ui/ResizableEmbedCard.js +358 -0
- package/dist/esm/ui/SmallerEditIcon.js +14 -0
- package/dist/esm/utils.js +48 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/messages.d.ts +12 -0
- package/dist/types/nodeviews/blockCard.d.ts +26 -0
- package/dist/types/nodeviews/datasource.d.ts +42 -0
- package/dist/types/nodeviews/embedCard.d.ts +46 -0
- package/dist/types/nodeviews/genericCard.d.ts +37 -0
- package/dist/types/nodeviews/inlineCard.d.ts +23 -0
- package/dist/types/plugin.d.ts +24 -0
- package/dist/types/pm-plugins/actions.d.ts +23 -0
- package/dist/types/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types/pm-plugins/analytics/types.d.ts +12 -0
- package/dist/types/pm-plugins/analytics/utils.d.ts +32 -0
- package/dist/types/pm-plugins/doc.d.ts +22 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/reducers.d.ts +3 -0
- package/dist/types/pm-plugins/shouldReplaceLink.d.ts +2 -0
- package/dist/types/pm-plugins/util/resolve.d.ts +8 -0
- package/dist/types/pm-plugins/util/state.d.ts +31 -0
- package/dist/types/toolbar.d.ts +9 -0
- package/dist/types/types.d.ts +163 -0
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +9 -0
- package/dist/types/ui/DatasourceModal/index.d.ts +11 -0
- package/dist/types/ui/EditLinkToolbar.d.ts +47 -0
- package/dist/types/ui/EditorSmartCardEvents.d.ts +5 -0
- package/dist/types/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +32 -0
- package/dist/types/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types/ui/LayoutButton/utils.d.ts +5 -0
- package/dist/types/ui/LinkToolbarAppearance.d.ts +29 -0
- package/dist/types/ui/ResizableEmbedCard.d.ts +61 -0
- package/dist/types/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types/utils.d.ts +19 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/messages.d.ts +12 -0
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +26 -0
- package/dist/types-ts4.5/nodeviews/datasource.d.ts +42 -0
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +46 -0
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +37 -0
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +23 -0
- package/dist/types-ts4.5/plugin.d.ts +24 -0
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +23 -0
- package/dist/types-ts4.5/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types-ts4.5/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/analytics/types.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/analytics/utils.d.ts +32 -0
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +22 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/reducers.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/shouldReplaceLink.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +31 -0
- package/dist/types-ts4.5/toolbar.d.ts +9 -0
- package/dist/types-ts4.5/types.d.ts +163 -0
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +9 -0
- package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +11 -0
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +47 -0
- package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +5 -0
- package/dist/types-ts4.5/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +32 -0
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types-ts4.5/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +5 -0
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +29 -0
- package/dist/types-ts4.5/ui/ResizableEmbedCard.d.ts +61 -0
- package/dist/types-ts4.5/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types-ts4.5/utils.d.ts +19 -0
- package/package.json +126 -0
- package/report.api.md +146 -0
- package/tmp/api-report-tmp.d.ts +117 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LifecycleEvent, SmartLinkEventsNext } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Simple mechanism to defer analytics related callbacks
|
|
4
|
+
*/
|
|
5
|
+
export declare const createAnalyticsQueue: (enabled?: boolean) => {
|
|
6
|
+
push: (...events: LifecycleEvent[]) => void;
|
|
7
|
+
flush: () => void;
|
|
8
|
+
setCallbacks: (callbacks: SmartLinkEventsNext) => void;
|
|
9
|
+
getSize: () => number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EditorState, ReadonlyTransaction, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { LifecycleEvent } from '../../types';
|
|
3
|
+
import { Link } from './types';
|
|
4
|
+
export declare const findChangedLinks: (tr: Transaction | ReadonlyTransaction, state: EditorState) => {
|
|
5
|
+
removed: Link[];
|
|
6
|
+
inserted: Link[];
|
|
7
|
+
updated: ({
|
|
8
|
+
removed: Link;
|
|
9
|
+
inserted: Link;
|
|
10
|
+
} | {
|
|
11
|
+
inserted: Link;
|
|
12
|
+
previous: {
|
|
13
|
+
display?: string;
|
|
14
|
+
};
|
|
15
|
+
})[];
|
|
16
|
+
};
|
|
17
|
+
export declare function eventsFromTransaction(tr: ReadonlyTransaction, state: EditorState): LifecycleEvent[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Node, Schema } from 'prosemirror-model';
|
|
2
|
+
import { ReadonlyTransaction, Transaction } from 'prosemirror-state';
|
|
3
|
+
import { Link } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Whether a node is a "link" node, ie inline card, block card, embed card
|
|
6
|
+
* (but not a text node with a link mark)
|
|
7
|
+
*/
|
|
8
|
+
export declare function isLinkNode(node: Node): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Analytics appearance for link object
|
|
11
|
+
*/
|
|
12
|
+
export declare function appearanceForLink(link: Link): "url" | import("@atlaskit/editor-common/provider-factory").CardAppearance;
|
|
13
|
+
/**
|
|
14
|
+
* Determine if a node is considered to be a link
|
|
15
|
+
*/
|
|
16
|
+
export declare const isLink: (schema: Schema, node: Node) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Given a node, find all nodes and marks that are considered "links"
|
|
19
|
+
* @param state EditorState
|
|
20
|
+
* @param fragment Fragment to search
|
|
21
|
+
* @returns Array of nodes and marks found in the fragment that are "links"
|
|
22
|
+
*/
|
|
23
|
+
export declare function findLinksInNode(doc: Node, schema: Schema, node: Node, offset: number): Link[];
|
|
24
|
+
export declare function getLinkUrl(link: Link): string | undefined;
|
|
25
|
+
export declare const getLinkNodeContext: (doc: Node, pos: number) => string;
|
|
26
|
+
export declare const linkObjectFromNode: (doc: Node, schema: Schema, node: Node, pos: number) => Link | undefined;
|
|
27
|
+
export declare const findLinksAtPositions: (tr: Transaction | ReadonlyTransaction, positions: number[]) => Link[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns whether or not two sets of links appear to likely be the same set of links
|
|
30
|
+
* That they are in the same order and that both their hrefs and appearances match
|
|
31
|
+
*/
|
|
32
|
+
export declare const areSameLinks: (linksA: Link[], linksB: Link[]) => boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import type { CreateUIAnalyticsEvent, UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
5
|
+
import { ACTION, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
7
|
+
import { CardAdf, CardAppearance, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
|
|
8
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { InlineCardAdf } from '@atlaskit/smart-card';
|
|
10
|
+
import { Request } from '../types';
|
|
11
|
+
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent) => Command;
|
|
12
|
+
export declare const handleFallbackWithAnalytics: (request: Request, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
13
|
+
export declare const queueCardsFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction?: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Transaction;
|
|
14
|
+
export declare const queueCardFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, previousAppearance?: CardAppearance | 'url') => Transaction;
|
|
15
|
+
export declare const convertHyperlinkToSmartCard: (state: EditorState, source: CardReplacementInputMethod, appearance: CardAppearance, normalizeLinkText?: boolean) => Transaction;
|
|
16
|
+
export declare const changeSelectedCardToLink: (text?: string, href?: string, sendAnalytics?: boolean, node?: Node, pos?: number, editorAnalyticsApi?: EditorAnalyticsAPI) => Command;
|
|
17
|
+
export declare const changeSelectedCardToLinkFallback: (text?: string, href?: string, sendAnalytics?: boolean, node?: Node, pos?: number, editorAnalyticsApi?: EditorAnalyticsAPI) => Command;
|
|
18
|
+
export declare const updateCard: (href: string, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
19
|
+
export declare const changeSelectedCardToText: (text: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
20
|
+
export declare const setSelectedCardAppearance: (appearance: CardAppearance, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
21
|
+
export declare const updateExistingDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView) => void;
|
|
22
|
+
export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { cardPlugin } from '../index';
|
|
4
|
+
import { CardPluginOptions, CardPluginState } from '../types';
|
|
5
|
+
export { pluginKey } from './plugin-key';
|
|
6
|
+
export declare const createPlugin: (options: CardPluginOptions, pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<CardPluginState>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { cardPlugin } from '../index';
|
|
4
|
+
import { CardPluginOptions } from '../types';
|
|
5
|
+
export declare const mountHyperlinkPlugin: (pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined, options: CardPluginOptions) => SafePlugin<any>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { CardOptions } from '@atlaskit/editor-common/card';
|
|
5
|
+
import { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
+
import { Request } from '../../types';
|
|
7
|
+
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf | DatasourceAdf>;
|
|
8
|
+
export declare const handleProvider: (_: 'cardProvider', provider: Promise<CardProvider> | undefined, view: EditorView) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EditorState, ReadonlyTransaction } from 'prosemirror-state';
|
|
2
|
+
import { CardPluginState, Request } from '../../types';
|
|
3
|
+
export declare const getPluginState: (editorState: EditorState) => CardPluginState | undefined;
|
|
4
|
+
export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState, tr: ReadonlyTransaction) => {
|
|
5
|
+
requests: {
|
|
6
|
+
pos: number;
|
|
7
|
+
url: string;
|
|
8
|
+
appearance: import("@atlaskit/editor-common/provider-factory").CardAppearance;
|
|
9
|
+
compareLinkText: boolean;
|
|
10
|
+
source: import("@atlaskit/editor-common/card").CardReplacementInputMethod;
|
|
11
|
+
previousAppearance?: "url" | import("@atlaskit/editor-common/provider-factory").CardAppearance | undefined;
|
|
12
|
+
analyticsAction?: import("@atlaskit/editor-common/analytics").ACTION | undefined;
|
|
13
|
+
shouldReplaceLink?: boolean | undefined;
|
|
14
|
+
sourceEvent?: import("@atlaskit/analytics-next").UIAnalyticsEvent | null | undefined;
|
|
15
|
+
}[];
|
|
16
|
+
cards: {
|
|
17
|
+
pos: number;
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
url?: string | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
|
|
22
|
+
showLinkingToolbar: boolean;
|
|
23
|
+
smartLinkEvents?: import("@atlaskit/smart-card").SmartLinkEvents | undefined;
|
|
24
|
+
smartLinkEventsNext?: import("../../types").SmartLinkEventsNext | undefined;
|
|
25
|
+
editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
|
|
26
|
+
showDatasourceModal: boolean;
|
|
27
|
+
datasourceModalType?: "jira" | undefined;
|
|
28
|
+
datasourceTableRef?: HTMLElement | undefined;
|
|
29
|
+
layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare const getNewRequests: (oldState: CardPluginState | undefined, currentState: CardPluginState) => Request[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { Command, ExtractInjectionAPI, FeatureFlags, FloatingToolbarHandler, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
4
|
+
import { CardPlatform } from '@atlaskit/smart-card';
|
|
5
|
+
import type { cardPlugin } from './index';
|
|
6
|
+
export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
7
|
+
export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
8
|
+
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
9
|
+
export declare const floatingToolbar: (cardOptions: CardOptions, featureFlags: FeatureFlags, platform?: CardPlatform, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>) => FloatingToolbarHandler;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
4
|
+
import { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
6
|
+
import { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
7
|
+
import { DatasourceTableLayout } from './ui/LayoutButton/types';
|
|
8
|
+
export type CardInfo = {
|
|
9
|
+
title?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
pos: number;
|
|
12
|
+
};
|
|
13
|
+
export type Request = {
|
|
14
|
+
/**
|
|
15
|
+
* The position of the link in the doc this request for upgrade is for
|
|
16
|
+
*/
|
|
17
|
+
pos: number;
|
|
18
|
+
/**
|
|
19
|
+
* The URL of the link being upgraded/resolved
|
|
20
|
+
*/
|
|
21
|
+
url: string;
|
|
22
|
+
/**
|
|
23
|
+
* The requested appearance to upgrade to
|
|
24
|
+
*/
|
|
25
|
+
appearance: CardAppearance;
|
|
26
|
+
/**
|
|
27
|
+
* Determines if the link should only be replaced after successful
|
|
28
|
+
* resolution if the link's text content still matches its href
|
|
29
|
+
* (ie has not been changed by the user since the resolve request).
|
|
30
|
+
*/
|
|
31
|
+
compareLinkText: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Analytics input method which preserves "how" the change
|
|
34
|
+
* has occured. Used when analytics are dispatched after the link
|
|
35
|
+
* is successfully/unsuccessfully resolved.
|
|
36
|
+
*/
|
|
37
|
+
source: CardReplacementInputMethod;
|
|
38
|
+
/**
|
|
39
|
+
* The previous appearance of the link
|
|
40
|
+
* This is necessary when tracking an update of a link
|
|
41
|
+
* where the link begins as a smart card, then is updated by
|
|
42
|
+
* replacing with a hyperlink and queueing it for upgrade
|
|
43
|
+
*/
|
|
44
|
+
previousAppearance?: CardAppearance | 'url';
|
|
45
|
+
/**
|
|
46
|
+
* Analytics action to be used when disaptching
|
|
47
|
+
* analytics events once the link is successfully/unsuccessfully
|
|
48
|
+
* resolved. Preserves the users "intent" ie was this a link
|
|
49
|
+
* being inserted or updated?
|
|
50
|
+
*/
|
|
51
|
+
analyticsAction?: ACTION;
|
|
52
|
+
/**
|
|
53
|
+
* Describes if the requested `appearance` MUST be returned by the card provider
|
|
54
|
+
* when resolving the link, because the request is associated with the user intent
|
|
55
|
+
* to explicitly change the link appearance to the target appearance (view switcher), and therefore
|
|
56
|
+
* should not be affected by "default appearances" or "user preferences"
|
|
57
|
+
*/
|
|
58
|
+
shouldReplaceLink?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Source UI that triggered this step if relevant
|
|
61
|
+
* Primarily for transfering link picker UI event from initial UI action
|
|
62
|
+
* through to the end of the link queue/request saga
|
|
63
|
+
*/
|
|
64
|
+
sourceEvent?: UIAnalyticsEvent | null | undefined;
|
|
65
|
+
};
|
|
66
|
+
export type Metadata<T = {}> = {
|
|
67
|
+
url: string;
|
|
68
|
+
display: string;
|
|
69
|
+
isUndo?: boolean;
|
|
70
|
+
isRedo?: boolean;
|
|
71
|
+
action?: string;
|
|
72
|
+
inputMethod?: string;
|
|
73
|
+
sourceEvent?: unknown;
|
|
74
|
+
nodeContext?: string;
|
|
75
|
+
} & T;
|
|
76
|
+
export type UpdateMetadata = {
|
|
77
|
+
previousDisplay?: string;
|
|
78
|
+
};
|
|
79
|
+
export type SmartLinkEventsNext = {
|
|
80
|
+
created: (metadata: Metadata) => void;
|
|
81
|
+
updated: (metadata: Metadata<UpdateMetadata>) => void;
|
|
82
|
+
deleted: (metadata: Metadata) => void;
|
|
83
|
+
};
|
|
84
|
+
export type LifecycleEventType = keyof SmartLinkEventsNext;
|
|
85
|
+
/**
|
|
86
|
+
* Describes the shape of an event that will be stored
|
|
87
|
+
* in the Card state until it can be dispatched
|
|
88
|
+
* as a side-effect in a view update
|
|
89
|
+
*/
|
|
90
|
+
export type LifecycleEvent<Type extends keyof SmartLinkEventsNext = keyof SmartLinkEventsNext> = {
|
|
91
|
+
type: Type;
|
|
92
|
+
data: Parameters<SmartLinkEventsNext[Type]>[0];
|
|
93
|
+
};
|
|
94
|
+
export type CardPluginState = {
|
|
95
|
+
requests: Request[];
|
|
96
|
+
provider: CardProvider | null;
|
|
97
|
+
cards: CardInfo[];
|
|
98
|
+
showLinkingToolbar: boolean;
|
|
99
|
+
smartLinkEvents?: SmartLinkEvents;
|
|
100
|
+
smartLinkEventsNext?: SmartLinkEventsNext;
|
|
101
|
+
editorAppearance?: EditorAppearance;
|
|
102
|
+
showDatasourceModal: boolean;
|
|
103
|
+
datasourceModalType?: DatasourceModalType;
|
|
104
|
+
datasourceTableRef?: HTMLElement;
|
|
105
|
+
layout?: DatasourceTableLayout;
|
|
106
|
+
};
|
|
107
|
+
export type CardPluginOptions = CardOptions & {
|
|
108
|
+
editorAppearance?: EditorAppearance;
|
|
109
|
+
platform: 'mobile' | 'web';
|
|
110
|
+
fullWidthMode?: boolean;
|
|
111
|
+
linkPicker?: LinkPickerOptions;
|
|
112
|
+
};
|
|
113
|
+
export type SetProvider = {
|
|
114
|
+
type: 'SET_PROVIDER';
|
|
115
|
+
provider: CardProvider | null;
|
|
116
|
+
};
|
|
117
|
+
export type Queue = {
|
|
118
|
+
type: 'QUEUE';
|
|
119
|
+
requests: Request[];
|
|
120
|
+
};
|
|
121
|
+
export type Resolve = {
|
|
122
|
+
type: 'RESOLVE';
|
|
123
|
+
url: string;
|
|
124
|
+
};
|
|
125
|
+
export type Register = {
|
|
126
|
+
type: 'REGISTER';
|
|
127
|
+
info: CardInfo;
|
|
128
|
+
};
|
|
129
|
+
export type ShowLinkToolbar = {
|
|
130
|
+
type: 'SHOW_LINK_TOOLBAR';
|
|
131
|
+
};
|
|
132
|
+
export type HideLinkToolbar = {
|
|
133
|
+
type: 'HIDE_LINK_TOOLBAR';
|
|
134
|
+
};
|
|
135
|
+
export type ShowDatasourceModal = {
|
|
136
|
+
type: 'SHOW_DATASOURCE_MODAL';
|
|
137
|
+
modalType: DatasourceModalType;
|
|
138
|
+
};
|
|
139
|
+
export type HideDatasourceModal = {
|
|
140
|
+
type: 'HIDE_DATASOURCE_MODAL';
|
|
141
|
+
};
|
|
142
|
+
export type RegisterSmartCardEvents = {
|
|
143
|
+
type: 'REGISTER_EVENTS';
|
|
144
|
+
smartLinkEvents: SmartLinkEvents;
|
|
145
|
+
};
|
|
146
|
+
export type RegisterSmartCardEventsNext = {
|
|
147
|
+
type: 'REGISTER_EVENTS_NEXT';
|
|
148
|
+
smartLinkEvents: SmartLinkEventsNext;
|
|
149
|
+
};
|
|
150
|
+
export type SetDatasourceTableRef = {
|
|
151
|
+
type: 'SET_DATASOURCE_TABLE_REF';
|
|
152
|
+
datasourceTableRef?: HTMLElement;
|
|
153
|
+
};
|
|
154
|
+
export type SetCardLayout = {
|
|
155
|
+
type: 'SET_CARD_LAYOUT';
|
|
156
|
+
layout: DatasourceTableLayout;
|
|
157
|
+
};
|
|
158
|
+
export type SetCardLayoutAndDatasourceTableRef = {
|
|
159
|
+
type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF';
|
|
160
|
+
layout: DatasourceTableLayout;
|
|
161
|
+
datasourceTableRef?: HTMLElement;
|
|
162
|
+
};
|
|
163
|
+
export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | RegisterSmartCardEventsNext | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { cardPlugin } from '../../plugin';
|
|
5
|
+
declare const ModalWithState: ({ api, editorView, }: {
|
|
6
|
+
api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
}) => JSX.Element | null;
|
|
9
|
+
export default ModalWithState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
5
|
+
type DatasourceModalProps = {
|
|
6
|
+
view: EditorView;
|
|
7
|
+
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
8
|
+
modalType?: DatasourceModalType;
|
|
9
|
+
};
|
|
10
|
+
export declare const DatasourceModal: ({ view, modalType }: DatasourceModalProps) => JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node } from 'prosemirror-model';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
5
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { HyperlinkAddToolbarProps } from '@atlaskit/editor-common/link';
|
|
7
|
+
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
8
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarConfig, FloatingToolbarItem, LinkInputType, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
9
|
+
import { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
10
|
+
import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
11
|
+
import type { cardPlugin } from '../plugin';
|
|
12
|
+
interface InjectionAPI {
|
|
13
|
+
pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
14
|
+
}
|
|
15
|
+
export type EditLinkToolbarProps = InjectionAPI & {
|
|
16
|
+
view: EditorView;
|
|
17
|
+
providerFactory: ProviderFactory;
|
|
18
|
+
url: string | undefined;
|
|
19
|
+
text: string;
|
|
20
|
+
node: Node;
|
|
21
|
+
onSubmit?: (href: string, text?: string, inputMethod?: LinkInputType, analytic?: UIAnalyticsEvent | null | undefined) => void;
|
|
22
|
+
linkPickerOptions?: LinkPickerOptions;
|
|
23
|
+
featureFlags: FeatureFlags;
|
|
24
|
+
forceFocusSelector: ForceFocusSelector | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare function HyperlinkAddToolbarWithState({ linkPickerOptions, onSubmit, displayText, displayUrl, providerFactory, view, onCancel, invokeMethod, featureFlags, onClose, onEscapeCallback, onClickAwayCallback, pluginInjectionApi, }: HyperlinkAddToolbarProps & InjectionAPI): JSX.Element;
|
|
27
|
+
export declare class EditLinkToolbar extends React.Component<EditLinkToolbarProps> {
|
|
28
|
+
componentDidUpdate(prevProps: EditLinkToolbarProps): void;
|
|
29
|
+
componentWillUnmount(): void;
|
|
30
|
+
/** Focus should move to the 'Edit link' button when the toolbar closes
|
|
31
|
+
* and not close the floating toolbar.
|
|
32
|
+
*/
|
|
33
|
+
private handleEsc;
|
|
34
|
+
private hideLinkToolbar;
|
|
35
|
+
render(): JSX.Element;
|
|
36
|
+
}
|
|
37
|
+
export declare const editLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
38
|
+
export declare const buildEditLinkToolbar: ({ providerFactory, node, linkPicker, featureFlags, pluginInjectionApi, }: {
|
|
39
|
+
providerFactory: ProviderFactory;
|
|
40
|
+
node: Node;
|
|
41
|
+
linkPicker?: LinkPickerOptions | undefined;
|
|
42
|
+
featureFlags: FeatureFlags;
|
|
43
|
+
pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
44
|
+
}) => FloatingToolbarItem<Command>;
|
|
45
|
+
export declare const editLinkToolbarConfig: (showLinkingToolbar: boolean, lpLinkPicker: boolean) => Partial<FloatingToolbarConfig>;
|
|
46
|
+
export declare const editDatasource: (node: Node, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
type AnalyticsBindingsProps = {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Binds the @atlaskit/link-analytics callbacks
|
|
9
|
+
* to the editor card plugin state events callbacks interfaces
|
|
10
|
+
*/
|
|
11
|
+
export declare const EventsBinding: ({ editorView }: AnalyticsBindingsProps) => null;
|
|
12
|
+
export declare class EditorSmartCardEventsNext extends React.PureComponent<AnalyticsBindingsProps> {
|
|
13
|
+
static contextTypes: {
|
|
14
|
+
contextAdapter: PropTypes.Requireable<object>;
|
|
15
|
+
};
|
|
16
|
+
render(): JSX.Element | null;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { EditorState } from 'prosemirror-state';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { IntlShape } from 'react-intl-next';
|
|
5
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { CardOptions } from '@atlaskit/editor-common/card';
|
|
7
|
+
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
8
|
+
import { CardProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
9
|
+
import { CardPlatform } from '@atlaskit/smart-card';
|
|
10
|
+
export interface HyperlinkToolbarAppearanceProps {
|
|
11
|
+
intl: IntlShape;
|
|
12
|
+
editorState: EditorState;
|
|
13
|
+
providerFactory: ProviderFactory;
|
|
14
|
+
url: string;
|
|
15
|
+
editorView?: EditorView;
|
|
16
|
+
platform?: CardPlatform;
|
|
17
|
+
cardOptions?: CardOptions;
|
|
18
|
+
editorAnalyticsApi: EditorAnalyticsAPI | undefined;
|
|
19
|
+
cardActions: CardPluginActions | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface HyperlinkToolbarAppearanceState {
|
|
22
|
+
supportedUrlsMap: Map<string, boolean>;
|
|
23
|
+
}
|
|
24
|
+
export declare class HyperlinkToolbarAppearance extends Component<HyperlinkToolbarAppearanceProps, HyperlinkToolbarAppearanceState> {
|
|
25
|
+
state: HyperlinkToolbarAppearanceState;
|
|
26
|
+
cardProvider?: CardProvider;
|
|
27
|
+
private getProvider;
|
|
28
|
+
private resolveUrl;
|
|
29
|
+
componentDidMount: () => Promise<void>;
|
|
30
|
+
UNSAFE_componentWillReceiveProps(nextProps: HyperlinkToolbarAppearanceProps): void;
|
|
31
|
+
render(): JSX.Element | null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
+
import { LayoutButtonProps, LayoutButtonWrapperProps } from './types';
|
|
5
|
+
export declare const LayoutButton: React.FC<LayoutButtonProps>;
|
|
6
|
+
declare const _default: React.FC<import("react-intl-next").WithIntlProps<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { IntlShape } from 'react-intl-next';
|
|
3
|
+
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { cardPlugin } from '../../index';
|
|
5
|
+
export type DatasourceTableLayout = 'full-width' | 'center' | 'wide';
|
|
6
|
+
export type LayoutButtonProps = {
|
|
7
|
+
mountPoint?: HTMLElement;
|
|
8
|
+
boundariesElement?: HTMLElement;
|
|
9
|
+
scrollableElement?: HTMLElement;
|
|
10
|
+
targetElement?: HTMLElement;
|
|
11
|
+
layout: DatasourceTableLayout;
|
|
12
|
+
onLayoutChange?: (layout: DatasourceTableLayout) => void;
|
|
13
|
+
testId?: string;
|
|
14
|
+
intl: IntlShape;
|
|
15
|
+
};
|
|
16
|
+
export interface LayoutButtonWrapperProps extends Pick<LayoutButtonProps, 'mountPoint' | 'boundariesElement' | 'scrollableElement'> {
|
|
17
|
+
api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
18
|
+
editorView: EditorView;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { EditorState } from 'prosemirror-state';
|
|
4
|
+
import { EditorView } from 'prosemirror-view';
|
|
5
|
+
import { IntlShape } from 'react-intl-next';
|
|
6
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
8
|
+
import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
9
|
+
import { CardContext } from '@atlaskit/link-provider';
|
|
10
|
+
import { CardPlatform } from '@atlaskit/smart-card';
|
|
11
|
+
export interface LinkToolbarAppearanceProps {
|
|
12
|
+
intl: IntlShape;
|
|
13
|
+
editorAnalyticsApi: EditorAnalyticsAPI | undefined;
|
|
14
|
+
currentAppearance?: CardAppearance;
|
|
15
|
+
editorState: EditorState;
|
|
16
|
+
editorView?: EditorView;
|
|
17
|
+
url?: string;
|
|
18
|
+
allowEmbeds?: boolean;
|
|
19
|
+
allowBlockCards?: boolean;
|
|
20
|
+
platform?: CardPlatform;
|
|
21
|
+
cardActions: CardPluginActions | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
|
|
24
|
+
static contextTypes: {
|
|
25
|
+
contextAdapter: PropTypes.Requireable<object>;
|
|
26
|
+
};
|
|
27
|
+
renderDropdown: (view?: EditorView, cardContext?: CardContext) => JSX.Element | null;
|
|
28
|
+
render(): JSX.Element | null;
|
|
29
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference path="../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { RichMediaLayout } from '@atlaskit/adf-schema';
|
|
6
|
+
import { ResizerProps } from '@atlaskit/editor-common/ui';
|
|
7
|
+
type State = {
|
|
8
|
+
offsetLeft: number;
|
|
9
|
+
resizedPctWidth?: number;
|
|
10
|
+
};
|
|
11
|
+
export type Props = Omit<ResizerProps, 'height' | 'width'> & {
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
aspectRatio: number;
|
|
15
|
+
};
|
|
16
|
+
export default class ResizableEmbedCard extends React.Component<Props, State> {
|
|
17
|
+
static defaultProps: {
|
|
18
|
+
aspectRatio: number;
|
|
19
|
+
};
|
|
20
|
+
state: State;
|
|
21
|
+
componentDidUpdate(): void;
|
|
22
|
+
get wrappedLayout(): boolean;
|
|
23
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
24
|
+
/**
|
|
25
|
+
* When returning to center layout from a wrapped/aligned layout, it might actually
|
|
26
|
+
* be wide or full-width
|
|
27
|
+
*/
|
|
28
|
+
checkLayout(oldLayout: RichMediaLayout, newLayout: RichMediaLayout): void;
|
|
29
|
+
calcNewSize: (newWidth: number, stop: boolean) => {
|
|
30
|
+
width: number | null;
|
|
31
|
+
layout: RichMediaLayout;
|
|
32
|
+
};
|
|
33
|
+
calcUnwrappedLayout: (pct: number, width: number) => 'center' | 'wide' | 'full-width';
|
|
34
|
+
get $pos(): import("prosemirror-model").ResolvedPos | null;
|
|
35
|
+
/**
|
|
36
|
+
* The maxmimum number of grid columns this node can resize to.
|
|
37
|
+
*/
|
|
38
|
+
get gridWidth(): number;
|
|
39
|
+
calcOffsetLeft(): number;
|
|
40
|
+
calcColumnLeftOffset: () => number;
|
|
41
|
+
wrapper?: HTMLElement;
|
|
42
|
+
get wideLayoutWidth(): number;
|
|
43
|
+
calcSnapPoints(): number[];
|
|
44
|
+
calcPxWidth: (useLayout?: RichMediaLayout) => number;
|
|
45
|
+
get insideInlineLike(): boolean;
|
|
46
|
+
highlights: (newWidth: number, snapPoints: number[]) => string[] | number[];
|
|
47
|
+
/**
|
|
48
|
+
* Previously height of the box was controlled with paddingTop/paddingBottom trick inside Wrapper.
|
|
49
|
+
* It allowed height to be defined by a given percent ratio and so absolute value was defined by actual width.
|
|
50
|
+
* Also, it was part of styled component, which was fine because it was static through out life time of component.
|
|
51
|
+
*
|
|
52
|
+
* Now, two things changed:
|
|
53
|
+
* 1. If `height` is present we take it as actual height of the box, and hence we don't need
|
|
54
|
+
* (or even can't have, due to lack of width value) paddingTop trick.
|
|
55
|
+
* 2. Since `height` can be changing through out life time of a component, we can't have it as part of styled component,
|
|
56
|
+
* and hence we use `style` prop.
|
|
57
|
+
*/
|
|
58
|
+
private getHeightDefiningComponent;
|
|
59
|
+
render(): jsx.JSX.Element;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Node, NodeType } from 'prosemirror-model';
|
|
2
|
+
import { EditorState } from 'prosemirror-state';
|
|
3
|
+
import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import type { CardInfo } from './types';
|
|
5
|
+
export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
|
|
6
|
+
export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
|
|
7
|
+
export type TitleUrlPair = {
|
|
8
|
+
title?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const titleUrlPairFromNode: (node: Node) => TitleUrlPair;
|
|
12
|
+
/**
|
|
13
|
+
* Merges the title and url from attributes and CardInfo from the resolved view, preferring the CardInfo.
|
|
14
|
+
* @param titleUrlPair title and url information from the node attributes
|
|
15
|
+
* @param info information stored in state from the resolved UI component view
|
|
16
|
+
*/
|
|
17
|
+
export declare const mergeCardInfo: (titleUrlPair: TitleUrlPair, info?: CardInfo) => TitleUrlPair;
|
|
18
|
+
export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleUrlPair;
|
|
19
|
+
export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
|