UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

28 lines 759 B
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils'; import { isDatasourceNode } from '../../pm-plugins/utils'; import { DATASOURCE_TABLE_LAYOUTS } from './types'; export const getDatasource = editorView => { if (editorView) { const { selection, schema } = editorView.state; const { blockCard } = schema.nodes; const findResult = findSelectedNodeOfType([blockCard])(selection); if (findResult && isDatasourceNode(findResult.node)) { return { ...findResult, node: findResult.node }; } } return { node: undefined, pos: undefined }; }; export const isDatasourceTableLayout = layout => { return DATASOURCE_TABLE_LAYOUTS.some(l => l === layout); };