@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
78 lines • 2.23 kB
JavaScript
import { pluginKey } from './plugin-key';
export const cardAction = (tr, action) => {
return tr.setMeta(pluginKey, action);
};
export const resolveCard = url => tr => cardAction(tr, {
type: 'RESOLVE',
url
});
export const queueCards = requests => tr => cardAction(tr, {
type: 'QUEUE',
requests: requests
});
export const registerCard = info => tr => cardAction(tr, {
type: 'REGISTER',
info
});
export const removeCard = info => tr => cardAction(tr, {
type: 'REMOVE_CARD',
info
});
export const registerRemoveOverlay = (callback, info) => tr => cardAction(tr, {
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
callback,
info
});
export const registerSmartCardEvents = smartLinkEvents => tr => cardAction(tr, {
type: 'REGISTER_EVENTS',
smartLinkEvents
});
export const setProvider = cardProvider => tr => cardAction(tr, {
type: 'SET_PROVIDER',
provider: cardProvider
});
export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr, {
type: 'SET_DATASOURCE_TABLE_REF',
datasourceTableRef
});
export const setResolvedToolbarAttributes = (url, attributes) => tr => cardAction(tr, {
type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
url,
attributes
});
export const setCardLayout = layout => tr => cardAction(tr, {
type: 'SET_CARD_LAYOUT',
layout
});
export const setCardLayoutAndDatasourceTableRef = ({
layout,
datasourceTableRef
}) => tr => cardAction(tr, {
type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
layout,
datasourceTableRef
});
export const showLinkToolbar = tr => cardAction(tr, {
type: 'SHOW_LINK_TOOLBAR'
});
export const hideLinkToolbar = tr => cardAction(tr, {
type: 'HIDE_LINK_TOOLBAR'
});
export const showDatasourceModal = modalType => tr => cardAction(tr, {
type: 'SHOW_DATASOURCE_MODAL',
modalType
});
export const hideDatasourceModal = tr => cardAction(tr, {
type: 'HIDE_DATASOURCE_MODAL'
});
export const clearOverlayCandidate = tr => cardAction(tr, {
type: 'CLEAR_OVERLAY_CANDIDATE'
});
export const setDatasourceStash = (tr, datasourceStash) => cardAction(tr, {
type: 'SET_DATASOURCE_STASH',
datasourceStash
});
export const removeDatasourceStash = (tr, url) => cardAction(tr, {
type: 'REMOVE_DATASOURCE_STASH',
url
});